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 <sipum14@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 HttpResponseRedirectDo the above & let me know. I hope it will work.--On Thu, 20 Jun, 2019, 2:41 PM ramadhan ngallen, <ngallen4@gmail.com> wrote:Hello Team--I created an app(called users) for user registrationIf user enter two mismatched password an app should redirect to the same page. otherwise it should redirect to the homepageUnfortunately when user enter two mismatched password it redirect to the wrong url http://127.0.0.1:8000/users/register/registerand also if user enter matched password it also redirect to the wrong url http://127.0.0.1:8000/users/register/registerits view.pyfrom django.shortcuts import render, redirectfrom 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.titlelast_name = request.POST['last_name']last_name = last_name.titleusername = 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 followsfrom . import viewsfrom django.urls import pathapp_name = 'users'urlpatterns = [path('register/', views.register, name='register'),]Settings.pyINSTALLED_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
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+unsubscribe@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.
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+unsubscribe@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.
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+unsubscribe@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.

No comments:
Post a Comment