Pages (feincms3.pages)¶
- class feincms3.pages.AbstractPage(*args, **kwargs)[source]¶
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 apositionfield for relatively ordering pages. While it is technically possible forpositionto be 0, e.g., data bulk imported from another CMS, it is not recommended, as thesave()method will override values of 0 if you manipulate pages using the ORM.is_active: Boolean field. Thesave()method ensures that inactive pages never have any active descendants.titleandslugpath: 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, whenTrue, allows you to fill in thepathfield all by yourself. By default,save()ensures that thepathfields are always composed of a concatenation of the parent’spathwith the page’s ownslug(with slashes of course). This is especially useful for root pages (setpathto/) or, when building a multilingual site, for language root pages (i.e./en/,/de/,/pt-br/etc.)
- get_absolute_url()[source]¶
Return the page’s absolute URL
If path is
/, reversespages:rootwithout any arguments, alternatively reversespages:pagewith an argument ofpath. Note that thispathis not the same asself.path– slashes are stripped from the beginning and the end of the string to make building an URLconf more straightforward.If any
reverse()call fails it falls back to returningself.pathprefixed with the script prefix which is/in the standard case.
- save(self, ..., save_descendants=None)[source]¶
Saves the page instance, and traverses all descendants to update their
pathfields and ensure that inactive pages (is_active=False) never have any descendants withis_active=True.By default, descendants are only updated when any of
is_activeandpathchange. This can be overridden by either forcing updates usingsave_descendants=Trueor skipping them usingsave_descendants=False.
- class feincms3.pages.AbstractPageQuerySet(model=None, query=None, using=None, hints=None)[source]¶
Defines a single method,
active, which only returns pages withis_active=True.- active()[source]¶
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.
- applications()[source]¶
Helper for transforming a queryset into the apps format
apps_urlconf()expects. The queryset isn’t filtered (on purpose) so you have to apply the.active()filtering yourself.