Hello!

I've got 3 objects, which have foreign keys pointing to each other. My
Wrapper class also contains a generic foreign key to my resource
class.

Is there a 'clean' way to create all 3 of the models at once? Or do I
have to allow the foreign keys to be null, and then go back and change
them later?

wrapper = Wrapper(name = resourceName, namespace = namespace)
rev = Revision(changedBy=user, wrapper = wrapper, comment =
self.cleaned_data['comment'])
resourceObj = TextResource(wrapper = wrapper,revision = rev, text =
self.cleaned_data['text'])

wrapper.latestResource = resourceObj

1. I can't save my wrapper object first, because it has a
'latestResource' foreign generic key...
2. I can't save my revision object, because it depends on the
wrapper...
3. I can't save my resource object, because it depends on both the
wrapper and revision object...

I saw this example, online: 
http://www.djangoproject.com/documentation/models/mutually_referential/,
but I don't think it works for generic foreign keys.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to