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|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by )
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.