13👍
✅
If you want to do it via code it is:
from django.http import HttpResponseRedirect
def frontpage(request):
...
return HttpResponseRedirect('/index/')
But you can also do it directly in the urls rules:
from django.views.generic import RedirectView
urlpatterns = patterns('',
(r'^$', RedirectView.as_view(url='/index/')),
)
For reference, see this post: https://stackoverflow.com/a/523366/5770129
3👍
What you could do, is the following. Put this in your urls.py:
url(r'^$',views.redirect_index),
and in your views:
def redirect_index(request):
return redirect('index')
- [Django]-Django view response time issues
- [Django]-How to use Apache to serve Django server and React client?
- [Django]-Errors When Installing MySQL-python module for Python 2.7
- [Django]-When does Django's custom model field method to_python get anything other than an instance?
- [Django]-How to call multiple views on one url in pinax
Source:stackexchange.com