- class feincms3.pages.AbstractPage(*args, **kwargs)#
Short version: If you want to build a CMS with a hierarchical page structure, use this base class.
It comes with the following fields:
parent: (a nullable tree foreign key) and a
positionfield for relatively ordering pages. While it is technically possible for
positionto be 0, e.g., data bulk imported from another CMS, it is not recommended, as the
save()method will override values of 0 if you manipulate pages using the ORM.
is_active: Boolean field. The
save()method ensures that inactive pages never have any active descendants.
path: The complete path to the page, starting and ending with a slash. The maximum length of path (1000) should be enough for everyone (tm, famous last words). This field also has a unique index, which means that MySQL with its low limit on unique indexes will not work with this base class. Sorry.
static_path: A boolean which, when
True, allows you to fill in the
pathfield all by yourself. By default,
save()ensures that the
pathfields are always composed of a concatenation of the parent’s
pathwith the page’s own
slug(with slashes of course). This is especially useful for root pages (set
/) or, when building a multilingual site, for language root pages (i.e.
Check for path uniqueness problems.
Return the page’s absolute URL
If path is
pages:rootwithout any arguments, alternatively reverses
pages:pagewith an argument of
path. Note that this
pathis not the same as
self.path– slashes are stripped from the beginning and the end of the string to make building an URLconf more straightforward.
reverse()call fails it falls back to returning
self.pathprefixed with the script prefix which is
/in the standard case.
- save(self, ..., save_descendants=None)#
Saves the page instance, and traverses all descendants to update their
pathfields and ensure that inactive pages (
is_active=False) never have any descendants with
By default, descendants are only updated when any of
pathchange. This can be overridden by either forcing updates using
save_descendants=Trueor skipping them using
- class feincms3.pages.AbstractPageQuerySet(model=None, query=None, using=None, hints=None)#
Defines a single method,
active, which only returns pages with
Return only active pages
This function is used in
apps_urlconf()and is the recommended way to fetch active pages in your code as well.
pathprefixed with the current script prefix