Opened 10 years ago

Closed 10 years ago

#1600 closed enhancement (fixed)

Omitting "Field" on ManyToManyField should throw an error

Reported by: pa-ching Owned by: adrian
Component: Metasystem Version: master
Severity: minor Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


If I write something like

class Post(models.Model):
    tags = models.ManyToMany(Tag)

instead of models.ManyToManyField, Django doesn't complain at all. However, any attempts to access (for example) tag_instance.post_set report that there is no such field, and there are probably other things that don't work. This is mainly due to my typing errors, but I've been bitten by this misspelling several times. I guess that I personally forget the Field suffix because ForeignKey doesn't have one. It isn't too big of a deal, but it might be nice for newbies like myself, and Django's error reporting has always been very helpful, either way. Thanks!

Change History (2)

comment:1 Changed 10 years ago by pa-ching

  • Version changed from magic-removal to SVN

comment:2 Changed 10 years ago by adrian

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

(In [2648]) Fixed #1600 -- Renamed ManyToMany to ManyToManyRel so people get a clearer error if they use ManyToMany instead of ManyToManyField

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