以下文字摘自一篇讨论,其中提到了redirect的几种方法:
1. HttpResponseDirect
2. redirect
3. url.py 中直接redirect
80 |
It's simple:
More info in the Update
There is apparently a better way of doing this in Django now using Example –
There is more in the |
||||||||
feedback
|
Depending on what you want (i.e. if you do not want to do any additional pre-processing), it is simpler to just use Django's redirect_to generic view:
See |
|||||||||||
feedback
|
There's actually a simpler way than having a view for each redirect – you can do itdirectly in
A target can be a callable as well as a string, which is what I'm using here. |
|||
feedback
|
Since Django 1.1, you can also use the simpler
It also takes an optional permanent=True keyword argument. |
|
feedback
|
With Django version 1.3, the class based approach is:
This example lives in in urls.py |
You can do this in the Admin section. It's explained in the documentation. https://docs.djangoproject.com/en/dev/ref/contrib/redirects/ |
版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则按侵权处理.
gia xe kia