man*_*uel 7 django django-middleware
当我收到包含单词"self"的路径的请求时,我希望在将其与URL匹配之前将其替换为用户ID.我尝试使用这样的中间件:
def process_request(self, request):
if '/self/' in request.path:
request.path = request.path.replace('/self/','/' + str(request.user.id) + '/')
Run Code Online (Sandbox Code Playgroud)
替换工作但显然是在URL匹配后完成的.在此之前有没有办法改变路径?
| 归档时间: |
|
| 查看次数: |
1922 次 |
| 最近记录: |