4 ms·
This is great and showcases Django's talent for basic CRUD apps with handy admin interfaces. One catch: I like to deploy static sites to GitHub Pages. It turns
by davepeck 3y ago
This is great and showcases Django's talent for basic CRUD apps with handy admin interfaces.
One catch: I like to deploy static sites to GitHub Pages. It turns out the Django ecosystem has an answer for that in the form of Django Distill [1]. Distill adds a new management command that generates static content by repeatedly invoking your views.
I've used Distill to build quite a few static sites. It's great to be able to deploy to Pages but use Django's admin UI locally. Typically, for these sites, I check in my 'production' SQLite database directly to my git repo.
(Combine this pattern with GitHub actions and you can do a lot with a little. For instance, here's a toy I built to summarize upcoming Seattle city council meetings [2].)
[1] https://github.com/meeb/django-distill https://github.com/meeb/django-distill
[2] https://scc.frontseat.org/ https://scc.frontseat.org/ -- source at https://github.com/front-seat/engage https://github.com/front-seat/engage
- deaddodo 3y agoI say this as someone that does like Django. I had the opposite opinion. If you were trying to convert Rails, Laravel or CakePHP users, this would just convince them that Django was more manual and involved than those frameworks. It would be better to utilize extensions like `scaffolding` to give a more equivalent workflow. It does demonstrate general MVC benefits and architecture, however.
- reidjs 3y agoYour links may be broken I was recently looking for a static site generator for a local relay race I help organize and django-distill was the top of my list. I ended up writing my own SSG because I had very little HTML that actually had to be generated on the site. But might check out django-distill in the future if you found it worth learning.
- lylejantzi3rd 3y agoCan you think of a complicated app that utilizes Django to its fullest extent? I'm trying to get a better view of what Django is capable of and I find it's helpful to see both the simplest example possible and the most complicated example possible. "Design for the extremes" as Don Norman would say.
- btown 3y agoInstagram's backend is a Django monolith "with several million lines of code and a few thousand Django endpoints" as of 2019, and the same architecture was used for Threads! They now run Django on a JIT-enabled fork of CPython, and leverage a ton of internal tooling for static analysis and strong typing. https://instagram-engineering.com/types-for-python-http-apis-an-instagram-story-d3c3a207fdb7 https://instagram-engineering.com/types-for-python-http-apis... https://engineering.fb.com/2023/09/07/culture/threads-inside-story-metas-newest-social-app/ https://engineering.fb.com/2023/09/07/culture/threads-inside... https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/ https://engineering.fb.com/2022/05/02/open-source/cinder-jit... https://engineering.fb.com/?s=django https://engineering.fb.com/?s=django Django is also excellent for e-commerce with projects like https://github.com/saleor/saleor https://github.com/saleor/saleor - or you can roll your own e-commerce system quite easily, which we've done at my travel startup.
- jenia2022 3y agoWhats your travelling startup?
- btown 3y agoI generally try not to publicly link my HN activity to my IRL identity, but my email's in my bio if you have any specific inquiries! To the larger point about Django and e-commerce, though, I'll share that we do a large volume of complex transactions where multiple funds flows for different parties need to be coordinated, so it's been vital to be able to have a dynamic data model to track the payables/receivables lifecycle of a given booking and add overrides/configurability to handle unique situations as they come along. Django's been a perfect match for that, the framework source code is very approachable (IMO much less "magical" than Rails in this regard while having the same level of expressivity and shorthand), and since it's Python, it works extremely well with data science tooling as well.
- lylejantzi3rd 3y agoThat is sufficiently complicated. Thank you!
- sanderjd 3y agoThis sounds like an awesome pattern, and I had no idea it exists!
- davepeck 3y agoIt’s a good one. Simon Willison calls it the “baked data pattern” — where a read-only copy of your data is checked into your repo alongside your code. [1] (And, just to tie the threads together, that’s the same Simon who wrote the OP we’re all commenting on, and who is also the co-creator of Django and more recently of the very handy Datasette!) [1] https://simonwillison.net/2021/Jul/28/baked-data/ https://simonwillison.net/2021/Jul/28/baked-data/
- meeb 3y agoYour use case and workflow is exactly why I originally developed django-distill, glad to see it resonates with other developers. Thanks!
- davepeck 3y agoThanks for Distill. The approach you took (specialized URL routes and custom management commands) is simple and elegant.