I think the problematic part is " create_user = UserCreationForm(request.
POST or None)"

Most FBV for forms start with the "if request.method == 'POST" and then
continue to fill the form. You can set the "None" after the if statement
instead of before everything else.

I am not sure that the or NONE syntax is working properly in your usage for
this. Could be wrong. I suggest to try using the boilerplate way.

On Fri, 23 Nov 2018 at 11:21, Tosin Ayoola <tosinayoo...@gmail.com> wrote:

> Good day Guys,
> working on a 3 step form but the issue now is that at the 2nd step the
> form instead of redirecting the user to the final step, it instead
> redirects back to the 1st step. below is my view, url code
> #Views
> def add_user(request):
> create_user = UserCreationForm(request.POST or None)
> if request.method == 'POST' and create_user.is_valid():
> create_user.save()
> return redirect(reverse('schoolprofile1'))
>
> return render( request, 'create_user_form.html',
> {'create_user': create_user,
> })
>
>
>
> def schoolprofile1(request):
> school_info = SchoolsForm(request.POST or None )
> if request.method == 'POST' and school_info.is_valid():
> request.session['school_data'] = school_info.cleaned_data
> return redirect(reverse('schoolprofile2'))
>
> return render(request, 'schoolprofile1.html',{
> 'school_info': school_info,
> })
>
>
> def schoolprofile2(request):
> school_info_two = SchoolDataForm(request.POST)
> if request.method == 'POST' and school_data.is_valid():
> complete_school_data_ = {
> **request.session['school_data'],
> **school_info_two.cleaned_data
> }
> Schools.object.create(**complete_school_data)
>
> return redirect('schoolDetail')
>
> return render(request, 'schoolprofile2.html',{
> 'school_data':school_info_two,
> })
>
> #URL
>
> urlpatterns = [
> path('', views.index, name = 'index'),
> path('schoolprofile/step-two', views.schoolprofile2, name='schoolprofile2'
> ),
> path('schoolprofile/step-one', views.schoolprofile1, name = '
> schoolprofile1'),
> path('schoolprofile/add-user', views.add_user, name= 'add_user'),
> path('schoolprofile', views.add_school, name='add_school'),
> #path(r'ProfileYourSchool', add_School.as_view([profileForm, SchoolsForm,
> schoolDataForm]), name = 'add_Schools'),
> path(r'ContactUs', views.Contact, name = 'Contact'),
> ]
>
>
> thanks
>
> --
> 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/CAHLKn73kTShkC7NsertLBbvrMnDp%3DJNQ0w2_iN41s-fVDiyRHw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAHLKn73kTShkC7NsertLBbvrMnDp%3DJNQ0w2_iN41s-fVDiyRHw%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/CA%2B%2Be-ZVDX%2BdzyJ4fJ2L7sKvDsDaOWJYKjUfRGTsROtGyxcEBwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to