4 ms·
This is surprising because the template language in particular feels so anti-PHP, it’s highly opinionated about not mixing code in with the template. I often wi
by nojs 1y ago
This is surprising because the template language in particular feels so anti-PHP, it’s highly opinionated about not mixing code in with the template. I often wish it supported arbitrary Python.
Anyway, thank you Simon :)
- simonw 1y agoYeah, the template language was strongly influenced by NOT wanting to allow arbitrary logic like PHP does. I was already a fan of Smarty - https://www.smarty.net/ https://www.smarty.net/ - which did a great job of separating out presentation logic in PHP. I've been using Jinja for my own projects for a few years because I wanted more expressive Python code in my templates! I think we didn't quite get the balance right for that in Django.
- robertlagrant 1y agoI think a great combo would've been Django's features, packaging and most importantly documentation, but with SQLAlchemy and Jinja2 technologies underneath.
- frankwiles 1y agoThat would have been hard since both of those projects came out after Django, but just an FYI Jinja2 templates are supported and nothing stops you from using SQLAlchemy. Granted you lose a lot of the tight intergration that makes Django great to use.
- robertlagrant 1y ago> That would have been hard since both of those projects came out after Django Well, yes I didn't mean Django from the start! I mean now.
- jefurii 1y agoThe nice thing about Django is that there's nothing stopping you from doing that. You'll have to give up the Django Admin if you use SQLAlchemy for models but you can still do it. I have several projects that use Elasticsearch as a backend and one that's based on JSON documents in Git repositories. You can totally do it!
- ashwinsundar 1y agoCustom tags and filters have been my escape hatches when the DTL is not taking me where I need to go. https://docs.djangoproject.com/en/5.2/howto/custom-template-tags/ https://docs.djangoproject.com/en/5.2/howto/custom-template-...