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 a position field for relatively ordering pages. While it is technically possible for position to 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.
  • title and slug
  • 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 path field all by yourself. By default, save() ensures that the path fields are always composed of a concatenation of the parent’s path with the page’s own slug (with slashes of course). This is especially useful for root pages (set path to /) or, when building a multilingual site, for language root pages (i.e. /en/, /de/, /pt-br/ etc.)
clean_fields(exclude=None)[source]

Check for path uniqueness problems.

get_absolute_url()[source]

Return the page’s absolute URL using reverse()

If path is /, reverses pages:root without any arguments, alternatively reverses pages:page with an argument of path. Note that this path is 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.

save(self, ..., save_descendants=None)[source]

Saves the page instance, and traverses all descendants to update their path fields and ensure that inactive pages (is_active=False) never have any descendants with is_active=True.

By default, descendants are only updated when any of is_active and path change. This can be overridden by either forcing updates using save_descendants=True or skipping them using save_descendants=False.

class feincms3.pages.AbstractPageManager[source]

Defines a single method, active, which only returns pages with is_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.

get_queryset()[source]

Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.