Once again Krylatij, I cant thank you enough for your help!

The content_types business has still been confusing me. Just to
confirm- i have a field in my super class :

    content_type =
models.ForeignKey(ContentType,editable=False,null=True)

Working through your example I above:

> p = Page.objects.get(id='main')
> #here we get ContentType object for PageText or PageGallery
> content_type = ContentType.objects.get_by_id(p.contenttype_id)

I got to this point and
"ContentType.objects.get_by_id(p.contenttype_id)" returned nothing.
Somehow I was expecting some kind of magic to have filled in the
content_type field when the sub classes were created! I found this on
django snippets http://www.djangosnippets.org/snippets/1031/ and so
added the save function to my superclass, Page. :

def save(self):
        if(not self.content_type):
            self.content_type =
ContentType.objects.get_for_model(self.__class__)
        self.save_base()

Im not sure if this was the kind of thing thats need or whether
there's an easier way of setting the content_type field in
subclasses.



--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to