I have spent some time in django, but templating seems to be:
- Non-productive
- Time consuming
- Difficult to manage the spaghetti code [ Django tags + HTML ]
I looked around for alternative and found:
- SASS [ CSS extension ] — For rails
- SLIM [ HTML extension ]
But I found non of the above specifically talking of django, neither did I found any of the above on the official django documentation.
So, Do we have any css / html extensions for django ?
Is it preffered to use these with django ?
Please talk about these in reference to django. [ Any guidance is appreciated ]
The reason you will not find any references to these in the official django documentation is because these are not bundled with the official django release. In addition, and more importantly – django (and python in general) doesn’t endorse any particular third party library as the next great Special Sauce to be used. If there is some third party component that does something particularly well – django will integrate it (as was the case with
django-staticfileswhich became part of the official django release).You will find community recommendations though. For example
lxmlis widely praised for xml/html parsing, however it is not officially endorsed in the Python documentation.Similarly with django they don’t endorse third party software to be used. Instead, they let you decide what fits your brain the best, which I prefer.
If you must, you can:
django_compressorHamlPyand thendjaml/Djinja/django-haml(or use the bundled hamlpy-watcher script which is similar to SASS’s watcher)SLIM seems to be a template engine for Ruby. If you are looking for alternates (again, I wouldn’t recommend this for sake of compatibility with other applications), you can use
jinja2with django.Keep in mind that django is a full stack framework, so everything is included in the box and is tightly integrated to get you running off the ground quickly. If you prefer a more “bring your own component” approach, you should explore other frameworks. The most pluggable one is
Pyramidwhich evolved from the excellentPylonsproject.