hello still it redirect to the wrong path http://127.0.0.1:8000/users/register/register
On Thu, Jun 20, 2019 at 12:24 PM Sipum Mishra <sipu...@gmail.com> wrote: > Hi Ramadhan, > > Instead of rendering to any page please use HttpResponseRedirect('put home > page url where u want to redirect' ). > > And also import django.http import HttpResponseRedirect > > Do the above & let me know. I hope it will work. > > On Thu, 20 Jun, 2019, 2:41 PM ramadhan ngallen, <ngall...@gmail.com> > wrote: > >> 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 >> <https://groups.google.com/d/msgid/django-users/CAAhXuBF07Q72_mi1AfPJ5LHHmaEdd5PhvQ79ToqSvpEt0gCivg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > 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/CAGHZBzx-XO4S58msQB%3DJmV9UAgDJmfk7dDOco2JZr4uXQer%3DYQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAGHZBzx-XO4S58msQB%3DJmV9UAgDJmfk7dDOco2JZr4uXQer%3DYQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAAhXuBGWZWtvpvXPg8U_Zj6VKFa2sqSJXNKUcx9N9K%3DoM-wbLw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.