Opened 18 years ago
Closed 13 years ago
#4212 closed Bug (invalid)
badly-defined ForeignKey to self does not cause an exception
Reported by: | Owned by: | Jonas Obrist | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a model something like this:
class MyModel(models.Model): my_model = ForeignKey('MyModel')
This mostly works, but I was confused when I found that instances didn't have a my_model_set attribute. I found that I should've defined my model like this:
class MyModel(models.Model): my_model = ForeignKey('self')
I can do that just fine, of course, but it was a bit non-obvious what the problem was. It'd be nice if defining that relationship improperly threw an exception.
Change History (6)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:5 by , 13 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
UI/UX: | unset |
comment:6 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Can't reproduce this issue, works fine for me.
Note:
See TracTickets
for help on using tickets.
Unfortunately it's kind of tricky to catch because that form is legal for getting around forward references to as-yet-undefined model classes, and for dealing with circular model dependencies. Probably still a good idea to see if we can do anything about it, though.