2👍
Do not create this functionality yourself but use the built-in Django auth views. https://docs.djangoproject.com/en/1.11/topics/auth/default/#built-in-auth-views
The only thing you need to do is add the contrib auth urls to your project:
urlpatterns = [
url('^', include('django.contrib.auth.urls')),
]
This gives you all views like login, logout, password reset etc.
If you want to customise the templates, copy the templates form /path/to/site-packages/django/contrib/admin/templates/registration/
to your app project/app/templates/registration/
and make any customisations
there.
If your app is listed before 'django.contrib.auth'
in INSTALLED_APPS
(it should always be like that) your custom templates will be picked first.
Source:stackexchange.com