Opened 19 years ago
Closed 19 years ago
#1487 closed defect (invalid)
docs/model-api for ForeignKeyField lacks option to specify model name
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Documentation | Version: | magic-removal |
Severity: | trivial | Keywords: | model |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The docs for ForeignKeyField in docs/model-api.txt state that you have to pass the model as the first argument.
Actually, you can also pass the model name.
I came upon this after trying something stupid and getting the following error message:
File "/home/mir/src/django/active/django/db/models/fields/related.py", line 410, in init
assert isinstance(to, basestring), "ForeignKey(%r) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string %r" % (to, RECURSIVE_RELATIONSHIP_CONSTANT)
AssertionError: ForeignKey(<class django_pop.email_admin.models.Ipkunde at 0xb74be41c>) is invalid. First parameter to ForeignKey must be either a model, a model name, or the string 'self'
I'm not sure if this actually works, but if not, then the error message is wrong ;-) I need this for cyclic foreign key references ... (no, it's not designed by me, so don't bash me about it ...)
Change History (1)
comment:1 by , 19 years ago
priority: | normal → lowest |
---|---|
Resolution: | → invalid |
Severity: | normal → trivial |
Status: | new → closed |
Forget this ticket, I missed the point that you can pass in the string "self". But you cannot pass any other string ...