Sorry, it was my mistake about:
> content_type = ContentType.objects.get_by_id(p.contenttype_id)
Try this:
> content_type = ContentType.objects.get_for_id(p.contenttype_id)
About overriding save() method see
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-predefined-model-method
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.ob
First of all about ContentTypes:
For example in your Page table you have 2 lines.
One is PageText, another PageGallery.
So you have 2 different ContentTypes.
How to determine type of Page:
p = Page.objects.get(id='main')
#here we get ContentType object for PageText or PageGallery
content_ty
Thanks again Krylatij,
I now have a super Page class and two sub classes GalleryPage and
TextPage. I can play around with the admin templates to stop the Page
class being instantiated but still display all pages on one page
ordered using an order field as suggested.
Is it possible for a instance
If you want to have some hierarchy for you pages, look at django-mptt,
but
with this inheritance type (non abstract) it works not correct (I have
added some changes to it to support this)
another way i describe below.
If you don't need hierarchy, so simple add 'order' field to Page
For hierachy:
Thanks krylatji.
The content_type field would replace the type field in my current
setup, right? I'll give that a go.
My next problem is a I need to allow the admin system to order the
pages, mixing both types of page. Hopefully I'll be able to figure
this out after reworking my app with your su
You can also inherit you GalleryPage and TextPage from your Page (not
Abstract).
Add content_type field to your Page. So it's easier to determine page
by it's id,
when i will write views.
After that register in admin only TextPage and GalleryPage.
Hope this helps
--~--~-~--~~
Hi,
Im building a back end for a simple flash site. The site can have any
number of pages and each page can be either an GalleryPage or a
TextPage. I would like to set up the admin system so that when a page
is added the appropriate TextPage or GalleryPage is displayed for
populating.
Simplified
8 matches
Mail list logo