On 04/04/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
>

> Firstly: You can forward reference a model by using its name as a string (
> e.g., ForeignKey("foo") works, in the same way that ForeignKey("self")
> works). However, IIRC, this only works with ForeignKeys in 0.91. In
> magic-removal, this has been fixed to encompass all field types.

Hmm... trying it like that brings up this error.

AssertionError: ForeignKey('Relationship') is invalid. First parameter
to ForeignKey must be either a model or the string 'self'

So it must be completly limited to magic removal.

> Second: To build an annotated m2m relation, what you probably want to do is
> something like:
>
> class Foo(Model):
>     data = meta.CharField()
>
> class Relation(Model):
>     from = ForeignKey(Foo, related_name="from")
>     to = ForeignKey(Foo, related_name="to")
>     data = meta.CharField()

Yeah, that's what I've done except with OneToOneField for from. I'll
refactor when some of magic-removal is reintroduced into the trunk.

Thanks,
Frankie.

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

Reply via email to