Hello Team I created an app(called users) for user registration If user enter two mismatched password an app should redirect to the same page. otherwise it should redirect to the homepage Unfortunately when user enter two mismatched password it redirect to the wrong url http://127.0.0.1:8000/users/register/register and also if user enter matched password it also redirect to the wrong url http://127.0.0.1:8000/users/register/register
its view.py from django.shortcuts import render, redirect from django.contrib.auth.models import User, auth # Create your views here. def register(request): if request.method == 'POST': first_name = request.POST['first_name'] first_name = first_name.title last_name = request.POST['last_name'] last_name = last_name.title username = request.POST['username'] password1 = request.POST['password1'] password2 = request.POST['password2'] email = request.POST['email'] if password1 == password2: user = User.objects.create_user( username=username, first_name=first_name, last_name=last_name, email=email, password=password1) user.save() print('user created') return redirect('/travello/') else: return render(request, 'users/register.html') else: return render(request, 'users/register.html') I have also created its urls.py as follows from . import views from django.urls import path app_name = 'users' *urlpatterns = [* * path('register/', views.register, name='register'),* ] Settings.py INSTALLED_APPS = [ * 'users.apps.UsersConfig',* 'travello.apps.TravelloConfig', 'calc.apps.CalcConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', user app directory [image: image.png] -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAhXuBF07Q72_mi1AfPJ5LHHmaEdd5PhvQ79ToqSvpEt0gCivg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.