Friday, November 30, 2018

Re: error in creating modelform for builtin user table

Ok  thanks guys for ur reply .
But I had found solution.
Just place Meta at meta

On Fri 30 Nov, 2018 7:00 pm Nagarjuna J <nagarjuna.j@enthsquare.com wrote:
i think add password2 in form fileds


On Fri, Nov 30, 2018 at 6:54 PM amit pant <amitpant945@gmail.com> wrote:
use variable instead of getusermodel

On Wed, Nov 28, 2018, 23:14 shiva kumar <kannamshivakumar417@gmail.com> wrote:
hello guys,
       i want to create a register form that user builtin user table . For that i used model form. here is code of forms.

forms.py
from django import forms
from .models import BlogPost
from django.conf import settings
from django.contrib.auth import get_user_model
User=get_user_model()
from django import forms


class register(forms.ModelForm):
class meta:

model=User
fields=['username','first_name','last_name','email','password'
]
password2 = forms.CharField(label='re-enter password', max_length=128)


and i used views.
views.py

def hidemeregister(request):
if request.method == 'POST':
form = register(request.POST)
if form.is_valid():
if form.cleaned_data['password']==form.cleaned_data['password2']:
form.save()
print(type(form))
return redirect('/hideme/blog/')
else:
form=register(get_user_model())
return render(request,'login.html',{'form':form})

and login.html 
i simple used form.as_p in login.html

i am getting error like this







please figure out where is the error

here i am using builtin user for register.


--
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/CAMsYeuHni67VsJBiWrC6w8seMFN0hpGrqQOJp1sAaSZGLtUHbQ%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/CAF2Ah_HxawKHpDRBeVn07XP2je8n8pVce5ukXMQ49Q3iaUrsNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks&Regards,
-------------------------
J.V.Nagarjuna Reddy,
7207203544,
8328031020.

--
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/CADK%2B6-B9pdSS-wJj%3DtssFNY-Hc%2BF%3D13rSh9VqQZ2mnuV0s8A1A%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/CAMsYeuGmMJM5QMjtCrL8J%3DJsnoXTTpYKb2b2bbhj8kPOQJ8cEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment