Weeknotes (2021 week 13 and 14)
Sorting django-admin-ordering instances in Python code
OrderableModel gained a
__lt__ function (and
functools.total_ordering) in 0.14 which allows sorting model instances in Python code. This is useful for my projects.
Some user agents do not like single quotes in OpenGraph tags
Django autoescapes content inserted into HTML (an excellent default). It also converts some special characters into entities (resp.,
html.escape does this). It seems that some user agents do not like entities in OpenGraph tags and show
&x27; instead of
'. Oh well. I added a workaround for this problem to feincms3-meta. It checks whether the value is safe1 and basically skips escaping in this case – at least I hope it is safe!
feincms3-forms – A new forms builder for the Django admin interface
For a current project we needed a forms builder with the following constraints:
- Simple fields (text, email, checkboxes, dropdowns etc.)
- Custom validation and processing logic
- It should be possible to add other content, e.g. headings and explanations between form fields
The form_designer fulfilled a few of these requirements but not all. It still works well but I wanted a forms builder based on django-content-editor for a long time already. Also, I really like the feincms3 pattern where the third party app only provides abstract models. Yeah, it is much more work to start with but the flexibility and configurability is worth it – especially since it’s possible to write straightforward code to handle special cases2 instead of configuring even more settings.
The humble beginnings are here in the feincms3-forms repository. The test suite already shows how things work together but as of now no documentation exists and no release has been made yet. I hope it will be ready for a first beta release in the next few weeks 😄