[Answered ]-Django define default view with IP address

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'),
    ...
]
👤Selcuk

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.

Leave a comment