Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#1299 closed defect (fixed)

ManyToManyField does not create set methods in auth.User model

Reported by: Stan Seibert <volsung@…> Owned by: adrian
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: UI/UX:

Description

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 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

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/init.py 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