Michael Radziej <mir@noris.de> reports that the following two models, which use the 'string' form of model reference in Foreign Keys, fail:
Version 1 (back referenced model):
class Wenga(models.Moldel):
...
class Benga(models.Model):
wenga = ForeignKey("Wenga")
Version 2: Forward referenced model
class Benga(models.Model):
wenga=ForeignKey("Wenga")
class Wenga(models.Model):
...
Version 2 succeeds syncdb, but fails on model import. Version 1 fails on syncdb with the same error that Version 2 provides during syncdb:
Traceback (most recent call last):
File "./manage.py", line 11, in ?
execute_manager(settings)
File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 1226, in execute_manager
execute_from_command_line(action_mapping)
File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 1152, in execute_from_command_line
action_mapping[action]()
File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 420, in syncdb
_check_for_validation_errors()
File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 956, in _check_for_validation_errors
num_errors = get_validation_errors(s, app)
File "/opt/local/lib/python2.4/site-packages/django/core/management.py", line 851, in get_validation_errors
for r in rel_opts.get_all_related_objects():
File "/opt/local/lib/python2.4/site-packages/django/db/models/options.py", line 121, in get_all_related_objects
if f.rel and self == f.rel.to._meta:
AttributeError: 'str' object has no attribute '_meta'