Custom tree handler¶
What to do if a time comes, and you need some fancy stuff done to tree items that django-sitetree does not support?
It might be that you need some special tree items ordering in a menu, or you want to render a huge site tree with all articles titles that are described by one tree item in Django admin, or god knows what else.
django-sitetree can facilitate on that as it allows tree handler customization
with the help of SITETREE_CLS setting.
- Subclass
sitetreeapp.SiteTreeand place that class into a separate module for convenience. - You may now override .apply_hook() to manipulate tree items before render, or any other method to customize handler to your exact needs.
- Define
SITETREE_CLSinsettings.pyof your project, showing it a dotted path to the subclass.
Example:
Note
You might also be interested in the notes on overriding admin representation.