Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1299 closed defect (fixed)

ManyToManyField does not create set methods in auth.User model

Reported by: Stan Seibert <volsung@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I have a model in my application which has a many-to-many relationship with Django's auth.User model:

from django.models.auth import User

class Category(meta.Model):
    name = meta.SlugField(maxlength=30, unique=True)
    desc = meta.CharField(maxlength=50)
    watchers = meta.ManyToManyField(User, related_name="watched_category")

Running help() on an instance of the User model shows that the appropriate get_vault_watched_category*() (the name of my app is "vault") methods were created, but no set_vault_*() method is there. I can only modify the many-to-many relation from the Category side of things.

Change History (1)

comment:1 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

The reverse set_* methods are only created for related models in the same app, but this behavior is fixed in the magic-removal branch (which will be rolled into Django's next version). If you need this functionality right away, you can remove this statement on line 57 of django/models/ in the current Django (and unindent the subsequent three lines):

if related.opts.app_label == klass._meta.app_label:

Note: See TracTickets for help on using tickets.
Back to Top