Opened 9 years ago

Closed 9 years ago

#1487 closed defect (invalid)

docs/model-api for ForeignKeyField lacks option to specify model name

Reported by: mir@… 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: UI/UX:

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 Changed 9 years ago by mir@…

  • priority changed from normal to lowest
  • Resolution set to invalid
  • Severity changed from normal to trivial
  • Status changed from new to closed

Forget this ticket, I missed the point that you can pass in the string "self". But you cannot pass any other string ...

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