#17299: The proxy model does not allow one to use ManyToMany fields
----------------------------------------------+--------------------
     Reporter:  anonymous                     |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.3
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 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
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17299>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en.

Reply via email to