Re: Adding values to formdata of ModelForm before saving

2012-06-03 Thread Peter of the Norse
Super is one of python’s greatest mistakes. http://docs.python.org/library/functions.html#super The form is class class_name(parent_class): def method(self, *args, **kwargs): super(class_name, self).method(*args, **kwargs) It’s better in Python 3, but Django hasn’t been ported over ye

Re: Adding values to formdata of ModelForm before saving

2012-06-01 Thread Schmidtchen Schleicher
Thank you for your effort, as far as I can see you understood my problem right and your solution could work... if there wouldn't be that error: TypeError at /kalender/1/new_termin/ super(type, obj): obj must be an instance or subtype of type Termin is a model class, NewTerminForm is a modelfor

Re: Adding values to formdata of ModelForm before saving

2012-05-31 Thread Kurtis Mullins
One minor edit to that: form.save(request) -> form.save(request, kalender) On Thu, May 31, 2012 at 8:47 PM, Kurtis Mullins wrote: > Hey, > > I tried re-writing your view and form for you -- but I ran into a snag. I > don't read German so other than code-wise (and a couple of obvious words, > like

Re: Adding values to formdata of ModelForm before saving

2012-05-31 Thread Kurtis Mullins
Hey, I tried re-writing your view and form for you -- but I ran into a snag. I don't read German so other than code-wise (and a couple of obvious words, like kalender and participants) I'm not really sure what you're trying to accomplish. I do see one obvious issue, though. Participants is a many

Re: Adding values to formdata of ModelForm before saving

2012-05-31 Thread bruno desthuilliers
On 31 mai, 20:09, Schmidtchen Schleicher wrote: > Thank you for your quick answer, but it doesn't really work. It raises the > exception "can't assign to operator" > My view now looks like this: > > @login_required > > def create_termin(request, calid, year=None, month=None, day=None): > >     kal

Re: Adding values to formdata of ModelForm before saving

2012-05-31 Thread Schmidtchen Schleicher
Thank you for your quick answer, but it doesn't really work. It raises the exception "can't assign to operator" My view now looks like this: @login_required > def create_termin(request, calid, year=None, month=None, day=None): > kalender = get_object_or_404(Kalender,pk=int(calid)) > if re

Re: Adding values to formdata of ModelForm before saving

2012-05-30 Thread Jonathan Baker
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 < spiolli...@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

Adding values to formdata of ModelForm before saving

2012-05-30 Thread Schmidtchen Schleicher
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