我有我的网址:
url(r'^home/', HomeQuestionView, name='home_question') ,
当我输入 localhost:8000/home 时,我得到了我的主页,但我想要的是当我刚输入时我得到了我的主页。 我的意思是当用户只输入我的网站时,我想重定向到上面的主页 url,比如 www.xyz.com 而不是 www.xyz.com/home
我不想这样配置
url(r'^', HomeQuestionView, name='home_question') ,
提前致谢
请您参考如下方法:
使用通用 RedirectView :
from django.views.generic.base import RedirectView
url(r'^$', RedirectView.as_view(url='/home/')),
