Re: models and forward declarations
Michael Radziej a écrit : > Rock schrieb: > >>Search for "forward reference" in this group. (Basically you cleverly >>locate your import statement inside a function call.) > > > I found your thread at: > > http://groups.google.com/group/django-users/browse_thread/thread/71fc72ab1f547d3/4d0dbfdfd9dc8a05?q=%22forward+references%22&rnum=2#4d0dbfdfd9dc8a05 > > > No, unfortunately, this doesn't work within the class itself but only > within a def. > > I tried, just to make sure, this: > > class Person(models.Model): > from django_pop.email_admin.models import Ipkunde > ... > uremip = models.ForeignKey(Ipkunde, db_column='ipkunde') > > class Ipkunde(models.Model): > ... > owner = models.ForeignKey(Owner, db_column='person') > Err... This has nothing to do with your question, but are you sure your data model is right ? The owner foreign key in Ipkunde means that a Person has one or more Ipkunde, and the uremip foreign key in Person means that a Ipkunde has one or more Persons. Seems like you want a many to many relationship here (which by the would solve your problem). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: models and forward declarations
Just found out that ForeignKeyField also accepts the model *name* instead of the model itself. Might solve the problem if this really works out :-) Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: models and forward declarations
Rock schrieb: > Search for "forward reference" in this group. (Basically you cleverly > locate your import statement inside a function call.) I found your thread at: http://groups.google.com/group/django-users/browse_thread/thread/71fc72ab1f547d3/4d0dbfdfd9dc8a05?q=%22forward+references%22&rnum=2#4d0dbfdfd9dc8a05 No, unfortunately, this doesn't work within the class itself but only within a def. I tried, just to make sure, this: class Person(models.Model): from django_pop.email_admin.models import Ipkunde ... uremip = models.ForeignKey(Ipkunde, db_column='ipkunde') class Ipkunde(models.Model): ... owner = models.ForeignKey(Owner, db_column='person') Result: Traceback (most recent call last): File "", line 1, in ? File "/home/mir/src/django_pop/../django_pop/email_admin/models.py", line 663, in ? class Person(models.Model): File "/home/mir/src/django_pop/../django_pop/email_admin/models.py", line 664, in Person from django_pop.email_admin.models import Ipkunde ImportError: cannot import name Ipkunde There's also another thread, about my problem, at http://groups.google.com/group/django-users/browse_thread/thread/24a996f32de9c112/35e4a288a7337db9#35e4a288a7337db9 but there's only someone else stating the same problem and no solution :-( Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: models and forward declarations
Search for "forward reference" in this group. (Basically you cleverly locate your import statement inside a function call.) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
models and forward declarations
Hi, I try to throw django on an existing database. Unfortunately, there are cyclic foreign key dependencies between tables, and I'm looking for a way to express this in the model. (I use the magic-removal branch from cvs). Is there a way? Something like class Bah(Models.model): ... class Igitt(Models.model): bah = Models.ForeignKeyField(Bah) ... Bah.igitt = Models.ForeignKeyField(Igitt) ? Any suggestions welcome ... I'm also interested whether anyone has tried to use an existing database with Django. Best regards, Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---