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.htmli simple used form.as_p in login.htmli am getting error like thisplease figure out where is the errorhere 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.
No comments:
Post a Comment