> does anybody knows, how to implement cross-refering models across files?
>
> Simple example:
> file 'models/a.py'
> class A(models.Model):
> ref_to_b = models.ForeignKey('B')
> ...
> class Meta:
> app_label = 'example_app'
>
> file 'models.b.py;
> class B(models.Model):
> ref_to_a = models.ForeignKey('A')
> ...
> class Meta:
> app_label = 'example_app'
Given your example, it sounds the following might be what you
describe (though I presume your files are example_app/models_a.py
and example_app/models_b.py):
# in example_app/models_a.py
class A(models.Model):
# no ref_to_b here
...
# in example_app/models_b.py
import a
class B(models.Model):
ref_to_a = models.OneToOneField(a.A,
related_name='ref_to_b')
# in example_app/models.py
from models_a import *
from models_b import *
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---