OK, I found the mistake myself.
The save() function has to return the new object. So this works:
def save(self, commit=True):
return super(CustomerForm, self).save(commit)
On 24 Sep., 13:58, Dennis Schmidt <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> I have a model (Customer) with a ManyToMany field referencing django's
> User class.
> Now in my admin panel I've created a custom Form (ModelForm subclass)
> for my Customer class. The only difference to the default form is that
> I added 3 new (ModelChoiceField) fields. The intention behind this is
> that I want to replace the default MultiSelectField for the model's
> ManyToMany field.
>
> Now my problem is that I don't know how to actually add / save these
> extra fields to my Customer model when it's saved.
> The form gets displayed correctly (and even validation works) but (of
> course?) django doesn't know how it should save my 3 custom fields. So
> everything else gets saved correctly (no errors) but my 3 User models
> won't get added to my Customer model.
>
> My first thought was I maybe have to override the ModelForm.save()
> method. So I tried this just to get started somewhere:
>
> def save(self, commit=True):
> super(CustomerForm, self).save(commit)
>
> but then, when I click "save" I just get the error message "'NoneType'
> object has no attribute 'save'" which is raised somewhere in a django
> function called save_model().
>
> So what am I doing wrong and how can I realize what I'm trying to do
> (allways adding 3 User objects to one Customer object)?
>
> Thanks in advance,
>
> Dennis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---