Sub-classing Page

17 views
Skip to first unread message

Barry

unread,
Jun 13, 2011, 8:56:37 AM6/13/11
to django-lfc
I can create a new content type that sub-classes from 'Page' instead
of (or as well as) BaseContent?

If I subclass from BaseContent my new content type works as in the
docs, but I want the rich text field of Page and some other new
fields. So I tried subclassing from Page and on trying to create an
object in the LFC admin I get and exception from django tagging:

Exception Value: 'BaseContent' object has no attribute 'page_ptr'
Exception Location: /home/rowlings/Web/CMS/Buildout/lfc-installer/
eggs/tagging-0.5-py2.6.egg/tagging/models.py in
get_all_parents_until_registered, line 68

The SQL generated when I subclass Page looks like this:

CREATE TABLE "talks_talkseries" (
"page_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES
"lfc_page" ("basecontent_ptr_id"),
"organiser" varchar(120) NOT NULL
)

whereas subclassing BaseContent looks like this:

CREATE TABLE "talks_talkseries" (
"basecontent_ptr_id" integer NOT NULL PRIMARY KEY REFERENCES
"lfc_basecontent" ("id"),
"organiser" varchar(120) NOT NULL
)

Not sure if that helps. I also tried subclassing both: class
TalkSeries(Page, BaseContent) but that failed too.

Maybe I'm being dumb and I should just copy the text field out of the
model.py definition for Page, but that breaks the idea of nice re-
usable classes...

Barry

Kai Diefenbach

unread,
Jun 13, 2011, 10:22:53 AM6/13/11
to django-lfc
Hi,

On 13 Jun., 14:56, Barry <b.rowling...@googlemail.com> wrote:
> I can create a new content type that sub-classes from 'Page' instead
> of (or as well as) BaseContent?

I haven't tried it, but I would expect it.
django-tagging sucks. Especially when it comes to inheritance. I had
to tweak it in order to make it work for LFC. The easiest thing would
be to subclass from BaseContent for now. I have planned to look into
django-taggit when I find some time.

Kai
Reply all
Reply to author
Forward
0 new messages