Thursday, May 31, 2012

Re: Adding values to formdata of ModelForm before saving

One minor edit to that: ->, kalender)

On Thu, May 31, 2012 at 8:47 PM, Kurtis Mullins <> wrote:

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-to-many field in your Model and you're also using the same attribute in your form. Here's something you could try in your form and view:

if request.method == 'POST':
    form = MyForm(request.POST)
    if form.is_valid():

def save(self, request, kalender, commit=True):

    # Get an Instance of the Termin object.
    obj = super(Termin, self).save(commit=True)
    # Add the user as a participant if 'add_me' = True
    if self.cleaned_data['add_me']:

    # Set the Calendar, Save, and return
    obj.in_calendar = kalender
    return obj

Hopefully I didn't just confuse you more :) Good luck!

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment