【发布时间】:2012-02-16 23:26:35
【问题描述】:
当我收到对包含单词“self”的路径的请求时,我想在将其与 URL 匹配之前将其替换为用户 ID。我尝试使用这样的中间件:
def process_request(self, request):
if '/self/' in request.path:
request.path = request.path.replace('/self/','/' + str(request.user.id) + '/')
替换有效,但显然是在 URL 匹配之后完成的。在此之前有什么方法可以改变路径吗?
【问题讨论】: