Code

Opened 8 years ago

Closed 8 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:

Description

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!

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by pa-ching

  • Version changed from magic-removal to SVN

comment:2 Changed 8 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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.