Django

Code

Ticket #1661 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: russellm Assigned to: russellm
Milestone: Component: Database wrapper
Version: magic-removal Keywords:
Cc: lists@knoggin.com Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by russellm)

njharman (lists@knoggin.com) reports:

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

Works.

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

Fails because whatever "turns" 'SomeModel?' from string into class object hasn't happened when code in "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/db/models/fields/related.py on line 510 tries to determine default to_field.


Model is ok during syncdb; failure occurs during import.

Attachments

Change History

06/23/06 22:38:55 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.
  • description changed.

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

10/24/06 15:17:23 changed by adrian

  • milestone deleted.

Milestone Version 0.92 deleted


Add/Change #1661 (Forward declaration of OneToOneField requires 'to_field' to avoid import failure)




Change Properties
Action