Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1661 closed defect (fixed)

Forward declaration of OneToOneField requires 'to_field' to avoid import failure

Reported by: Russell Keith-Magee Owned by: Russell Keith-Magee
Component: Database layer (models, ORM) Version: magic-removal
Severity: normal Keywords:
Cc: lists@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Russell Keith-Magee)

njharman (lists@…) reports:

class Foo(models.Model):
   myfield = models.OneToOneField('SomeModel', to_field='id')


class Foo(models.Model):
   myfield = models.OneToOneField('SomeModel')

Fails because whatever "turns" 'SomeModel' from string into class object
hasn't happened when code in
on line 510 tries to determine default to_field.

Model is ok during syncdb; failure occurs during import.

Change History (2)

comment:1 Changed 13 years ago by Russell Keith-Magee

Description: modified (diff)
Resolution: fixed
Status: newclosed

(In #3197) Fixed #1661 -- Added logic for string-form model references in the 'to' argument of OneToOneFields?. Includes regression test.

comment:2 Changed 12 years ago by Adrian Holovaty

milestone: Version 0.92

Milestone Version 0.92 deleted

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