On Tue, Jan 23, 2018 at 10:10 PM, harsh sharma <[email protected]>
wrote:

> i am trying to save the basic information about a person
> i have created a model form for it but i am unable to save the object
> (unable to update the database)
>
> here is my views file
>
> @login_required
> def dashboard(request):
>     if request.method=="post":
>         form = linkform(request.POST)
>         if form.is_valid():
>             try:
>                 notes = form.cleaned_data['note']
>                 link = form.cleaned_data['link']
>                 number = form.cleaned_data['number']
>                 perso = person.object.create_person(notes,link,number)
>                 perso.save()
>                 return HttpResponse('succeess')
>             except:
>
>
Your "except" swallows the exceptions that are happening and you're unable
to figure out the reason it's failing.


> class personmanager(models.Manager):
>     def create_person(self,note,link,number):
>         pers = self.create(note=note,link=link,number=number)
>         return pers
>
>
The problem is due to your use of "note" whereas the field name
is actually "notes" (plural)

Finally, the entire "create_person" serves no purpose as you're just
aliasing "create"

person.object.create_person(a=a, b=b, c=c)
Person.objects.create(a=a, b=b, c=c)

Regards,

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/CAFwtXp2T9MvcF3QpC7W4i%2B8QL8VQZLt9HVUbRe%3DBpugPUSxwnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to