Re: models and forward declarations

2006-03-11 Thread bruno modulix

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=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

2006-03-09 Thread Michael Radziej

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

2006-03-09 Thread Michael Radziej

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=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

2006-03-09 Thread Rock

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
-~--~~~~--~~--~--~---