2👍
✅
Include this in views.py file of your any app:
from django.shortcuts import redirect
def some_view(request):
return redirect('/Home/login/')
Suppose the view is in log app then,
Include this in your urls.py:
from log.views import some_view
urlpatterns = [
url(r'^$', some_view,name='index'),
url(r'^admin/', admin.site.urls),
url(r'^BirthCertificate/', include('BirthCertificate.urls')),
url(r'^Identity/', include('Identity.urls')),
url(r'^Accueil/', include('Accueil.urls')),
url(r'^Home/', include('log.urls')),
url(r'^captcha/', include('captcha.urls')),
url(r'^Mairie/', include('Mairie.urls')),
]
0👍
One method is to use RedirectView
by making the following changes to your urls.py
:
from django.views.generic.base import RedirectView
urlpatterns = [
url(r'^$', RedirectView.as_view(url='/Home'), name='home'),
...
]
- [Answered ]-Remove trailing data from django timesince — template equivalent
- [Answered ]-Using a class as a part of another class in django models
- [Answered ]-How to show choices of field in another table(model) value?
- [Answered ]-Restrict foreign key values according to request.user in django
- [Answered ]-Python tests. Patch method from library in venv
0👍
You can either do this in Django or Configure from your webserver. Django has redirects app go through https://docs.djangoproject.com/en/1.10/ref/contrib/redirects/ for more info. You just add the source and redirect urls in the redirects section of your django admin.
- [Answered ]-How to save m2m field on Django with commit=False?
- [Answered ]-How to create dynamic table in postgresql with django
- [Answered ]-Django – TDD: 'HttpRequest' has no attribute 'POST'
- [Answered ]-Adding Additional Hallo.js formatting features to Wagtail CMS RichTextField
- [Answered ]-How to display new line input text in new line?
Source:stackexchange.com