Answer the question
In order to leave comments, you need to log in
How to fix ViewDoesNotExist error in Django?
Django 1.9.2
Error:
ViewDoesNotExist at /auth/registration/
Could not import 'loginsys.views.registration'. View does not exist in module loginsys.views.
____________________
Main file url.py
from django.conf.urls import include, url
from django.contrib import admin
from bakot import urls as bakot_urls
from loginsys import urls as loginsys_urls
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^', include(bakot_urls)),
url(r'^auth/', include(loginsys_urls)),
]
from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from loginsys import views
urlpatterns = [
url(r'^login/', views.login, name='login'),
url(r'^logout/', views.logout, name='logout'),
url(r'^registration/', views.registration, name='registration'),
url('^', include('django.contrib.auth.urls'))
]
from django.contrib import auth
from django.shortcuts import render, redirect, render_to_response
from django.template.context_processors import csrf
from django.contrib.auth.forms import UserCreationForm
from loginsys.models import UserCreationCustomForm
def registration(request):
args = {}
args.update(csrf(request))
args['form'] = UserCreationCustomForm()
if request.POST:
newuser_form = UserCreationCustomForm(request.POST)
if newuser_form.is_valid():
newuser_form.save()
newuser = auth.authenticate(username = newuser_form.cleaned_data['username'], password = newuser_form.cleaned_data['password2'])
auth.login(request, newuser)
return redirect('/step3')
else:
args['form'] = newuser_form
return render_to_response('registration.html', args)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question