The proxy model does not allow one to use ManyToMany fields
|Reported by:||anonymous||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.3|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Suppose I have an app where the users may write messages. Then suppose that users must be able to follow one another in a twitter-like fashion. As far as I see, the most clean solution will be to create a non-symmetrical self-referencing m2m relation on the contrib.auth.models.User. Editing the code in contrib.auth.models.User itself will be naturally be an outrage, so I'll need to define a model inheriting from User and define the m2m relation there but this will lead to the creation of a new DB table for the descendant which will contain only the id field. In order to avoid this, one would suppose that he should be able to define the descendant as a proxy model, as the new m2m relation doesn't really affect the database representation of contrib.auth.User besides creating foreign keys to the intermediary model.
Unfortunately, the following code will result in "django.core.exceptions.FieldError: Proxy model 'MyUser' contains model fields":
from django.contrib.auth import models class MyUser(models.User): subscription = models.ManyToMany('self', symmetrical=False) class Meta: proxy = True