When using django-terms, your HTML pages are totally or partially reconstructed:
- totally reconstructed if you use the Middleware
- partially reconstructed if you use the Template filter or With django-CMS
The content is parsed and rebuilt with beautifulsoup4. See terms/html.py to understand exactly how.
List of known side effects¶
A few side effects are therefore happening during HTML reconstruction:
- Entity names and numbers (e.g. é, é, …) are unescaped. This means they are replaced with their unicode characters (e.g. é -> é)
- Additional spaces inside HTML tags are stripped:
- Start tags <a href = "url" > -> <a href="url">
- End tags </ a > -> </a>
- “Start-end” tags <input style = "text" /> -> <input style="text"/>
This implies one bad side effect: the unescaping breaks the special characters rendering in some complex form fields like django-ckeditor. django.contrib.admin is already ignored, so you should not encounter any problem. Otherwise, using filters instead of the middleware and/or ignore the correct apps/tags/classes/ids using Common settings will ensure a proper rendering.
django-terms nearly never hits the database. After each change in your terms table, the database is hit just one time in order to build a regular expression that’s saved into your cache (assuming you set up the cache). If you never change your terms and if your cache is never emptied, there will zero database hits.
Considering memory, no particular leak has been found.
What is important is the number of HTML tags wrapped by the filter or the middleware. Then comes the complexity of your HTML tree. The amount of flat text, luckily, has no impact.
To give you an idea, terms/tests/terms/performance_test_before.html contains 263 tags and takes 45 ms to be parsed and rebuilt on my computer with the middleware. That gives an average of 160 µs per tag. If you use the template tag only on the content of the page (124 tags), it takes 28 ms. Quite slow, but if you cache the part of the template that’s filtered, this issue should be negligible.
|Raised by:||Middleware only.|
|Raised in:||TERMS_DEBUG mode. Otherwise the page is ignored by django-terms.|
|Reason:||This happens when django-terms is unable to resolve the current request.path to determine whether the application of the current page is in TERMS_IGNORED_APPS.|
|Encountered:||In django-CMS 2.3, when adding a plugin in frontend editing.|