Wednesday, May 30, 2012

Re: Adding values to formdata of ModelForm before saving

Yes, it is possible:

obj = form.save(commit=False)
obj.in_calender-id = kalender
obj.save()


On Wed, May 30, 2012 at 2:56 PM, Schmidtchen Schleicher <spiollinux@googlemail.com> wrote:
Is it possible to put missing data into the data of a form before calling form.save() ?
I want to add the calendar-id (calid/in_calendar) before saving to the model.

 http://susepaste.org/23451355

I tried adding it after instantiating the form with form.in_calendar_id = kalender but it didn't work
I don't want to use hidden fields because manipulating them is easy

Maybe https://groups.google.com/forum/?fromgroups#!topic/django-users/F5yHH-G5QLM describes how to solve it but I didn't understand it.

PS: If you find very ugly code please correct me -- I'm a beginner

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/v0GYTeLYPAsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Jonathan D. Baker
Developer
http://jonathandbaker.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment