I tested this with SQLite3 and it worked, using your models:

>>> a.users = User.objects.all()
>>> a.save()
>>> a.delete()
>>> a = AccountTypeA(name='aaaa')
>>> a.save()
>>> a.users = User.objects.all()

After that:
sqlite> select * from testapp_accounttype_users;
1|1|1

Which is what I should expect considering I have only one user and only one 
account. Could you have an issue in another part of the code?

Regards,
Camilo.

On Tuesday, April 1, 2014 6:38:40 AM UTC-4:30, Izidor Matušov wrote:
>
> Hi,
>
> I've run into interesting issue and I'm not sure if I do something wrong 
> or this is Django issue. I'm using Multi Table Inheritance:
>
> <code>
> from django.db import models
> from django import forms
>
> class AccountType(models.Model):
>     users = models.ManyToManyField('auth.User', related_name='accounts')
>
>
> class AccountTypeA(AccountType):
>     name = models.CharField(max_length=255)
>
>
> class AccountTypeAForm(forms.ModelForm):
>     class Meta:
>         model = AccountTypeA
>         fields = ('name', 'users')
> </code>
>
> However, users are not saved in database. Find out that ModelForm calls 
> `self.instance.users = <list-of-users>` but that's not get saved. Even 
>
> <code>
> account = AccountTypeA(name='something')
> account.save()
> account.users = User.objects.all()
> </code>
>
> is not propagated. However, account.accounttype.users works perfectly 
> fine. Do I do something wrong?
>
> P.S: I'm using Django 1.6
>
> Izidor
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/42408986-0366-49e5-a8fe-d80b783d8def%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to