Hello James, 
Thanks a lot for reply. There are couple of things that I would like to bring 
to the notice
1) I did go through that part of django document before posting the issue 
here.2) In that doc, in the 2nd "if" condition, its talking about cleaned_data. 
In one of the public forum, I was asked to remove that part from my views.py, 
as I am not customizing my models.py. If I use cleaned_data. I entered the 
below in my earlier view.py
            #username = form.cleaned_data.get('username')            #password 
= form.cleaned_data.get('password')            #email = 
form.cleaned_data.get('email')            #user.save()
Please let me know if that was right? Also, can you point me to the exact 
changes that you want me to make in my views.py. I am sorry that I am asking 
this, but over the last 2 week or so, I am so frustrated that I am not able to 
think much on this part. 



Hello,
Regards,Amitesh Sahay


primary :: 91-907 529 6235
 

    On Friday 17 November 2017, 12:04:25 PM IST, James Schneider 
<jrschneide...@gmail.com> wrote:  
 
 

On Nov 15, 2017 8:32 AM, "'Amitesh Sahay' via Django users" 
<django-users@googlegroups.com > wrote:

Hello Members, 
I am new to Django, and trying to create a mock Django registration page. I am 
using default Django "User" model to do that, and I am not customizing 
anything. Its a very simple form with 3 fields as follows:
'username','password','email'. Below are my python and html code details:

Snip...

views.py--------
def SignUpFormView(request):    user_form = 'SignUpForm'

    template_name = 'test.html'
    if request.method == 'POST':        form = user_form(request.POST)        
if form.is_valid():            form.save()            #username = 
form.cleaned_data.get('usernam e')            #password = 
form.cleaned_data.get('passwor d')            #email = 
form.cleaned_data.get('email')            #user.save()            return 
render(request, template_name, {'form':form})

    else:        SignUpForm()
    return render(request, 'user_info/about.html') 

Snip...

My issue is, when trying to launch the "register" page, its not going inside 
"if" condition in views.py, rather its going directly to "else" condition. 
I am tried many things under my reach, but couldn't resolve the issue, and 
stuck for 2 weeks now. Any help would be appreciated.

There are several issues with the view composition. Please refer to the docs 
here and verify your syntax matches the example:
https://docs.djangoproject.com/en/1.11/topics/forms/#the-view

Your template code also suggests that you are seeing duplicate form fields (or 
perhaps they are being rendered in the source but aren't visible). It's also 
possible that the Django form is not being created correctly in the first 
place, which is why you need to manually render the form fields, when the {{ 
form.as_p }} should be doing that for you.
If you are submitting the form and getting the behavior you describe, I'm 
guessing that the if statement isn't being skipped, but the values being 
submitted do not match the form object in Django, causing it to fail 
validation, meaning that the second if statement is coming back False.
-James

-- 
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%2Be%2BciWNrWLhEzhM6649BsP5JByUXbsS7gvBVaKq2BkejKH7Rw%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+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/1670974142.510163.1510916854178%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to