Hello, from which repos ?
On Thu, Jun 6, 2019 at 7:50 PM anchal agarwal <agarwalanchal72@gmail.com> wrote:
Hello,--I am making a simple user form but my form data is not saving.It is showing this error'UserForm' object has no attribute 'save'Here is my code. Please tell me where i am wrongviews.pyclass UserFormView(View):form_class=UserFormtemplate_name='music/registration_form.html'#display blank formdef get(self , request):form=self.form_class(None)return render(request,self.template_name,{'form':form})#process from datadef post(self, request):form=self.form_class(request.POST)if form.is_valid():user=form.save(commit=False)#cleaned (normalized) datausername=form.cleaned_data['username']password=form.cleaned_data['password']user.set_password(password)user.save()#returns User objects if credentials are correctuser=authenticate(username=username,password=password)if user is not None:if user.is_active:login(request,user)return redirect('music:index')return render(request,self.template_name,{'form':form})forms.pyfrom django import formsfrom django.contrib.auth.models import Userclass UserForm(forms.Form):password=forms.CharField(wiget = forms.PasswordInput)class Meta:model=Userfields=['username','email','password']
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/CAMT%3DisXLE0z7ADcBzB-LhDf%2BU9_ZNVrhitBAVrSDwQCSKEfNZg%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/CACGjKra8_nF%2BcymQogX9Y0iQbNt0nG9mLWv6kfB_4OVJB-HC1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment