6 ms·
I love Django. I've used it for the last 8 years. I'm happy to see the project is still thriving. At this point, for me Django is pretty much synonymous with D
by mkolodny 8y ago
I love Django. I've used it for the last 8 years. I'm happy to see the project is still thriving.
At this point, for me Django is pretty much synonymous with Django REST framework (https://www.django-rest-framework.org/ https://www.django-rest-framework.org/). I can't imagine a better API than Django w/ REST framework.
For static sites I use Django's templates. Otherwise, I just use Django w/ REST framework for my API, and to serve up index.html. My index.html will include a link to my JS bundle(s) - I use a separate build system (Webpack/Babel/etc) to handle JS.
- konschubert 8y agoTry serving your static content from a specialized host, for example firebase hosting. Then, you don’t need to serve any static content from your API server and can do away with nginx. Use the whitenoise package for serving the Django admin pages if you still need them for administrative tasks.
- 1337shadow 8y agoOr serve statics from uWSGI (which also provides a spooler, cron and shared cachemem that works with python and Django but that's another story), here in optimized version for best results according to lighthouse: uwsgi --plugin=python3,http,router_static,router_cache --mime-file /etc/mime.types --offload-threads '%k' --file-serve-mode x-accel-redirect --route '^/static/.* addheader:Cache-Control: public, max-age=7776000' --static-map $STATIC_ROOT=$STATIC_URL --static-gzip-all --cache2 'name=statcalls,items=100' --static-cache-paths 86400 --static-cache-paths-name statcalls"
- jadiofan 8y agoSane defaults FTW
- systemspeed 8y agoI do wish Django REST Framework shipped with faster serializer code.
- Nextgrid 8y agoYou can use Serpy for that, although it will require some hacking for deserialization (a previous client of mine had a custom-built solution that used Serpy for responses but plain Form classes for parsing requests, but that seemed fine and they were handling 3k/requests per second at peak time).
- tclancy 8y agoI never quite got Serpy working, but swapping to uJSON and the DRF renderer[0] helped quite a bit in some cases. [0] https://github.com/gizmag/drf-ujson-renderer https://github.com/gizmag/drf-ujson-renderer
- systemspeed 8y agoThat's essentially what we ended up doing, selectively using Serpy for certain slow responses. It still felt hackish though, as though we were taking the brakes off certain responses because we knew they needed little validation (IIRC). DRF serializers still need work; marshmallow provides a similar feature set to DRF but serializes almost twice as fast: https://voidfiles.github.io/python-serialization-benchmark/ https://voidfiles.github.io/python-serialization-benchmark/ Disclaimer: The above is not my project
- ibejoeb 8y agoDRF is awesome. If you're considering moving to or implementing GraphQL, though, Django + Graphile is amazingly productive and performant. No affiliation, just good experiences. https://www.graphile.org/postgraphile/ https://www.graphile.org/postgraphile/
- milquetoastaf 8y agoOh man Graphile is exactly what I've been looking for my own project at work. And it worked right out of the box with one command. Thank you so very much!
- RussianCow 8y agoIf you're using Postgraphile for the API layer and a frontend framework for the view layer, what do you need Django for? Just migrations?
- nouveaux 8y agoPostgraphile solves the problem of boilerplate CRUD very well but it does not handle custom and complex logic well. For instance, interacting with other APIs like payment.
- BenjieGillam 8y agoI’m sorry you feel that way; I use PostGraphile with external APIs frequently, using makeExtendSchemaPlugin to easily add more types and resolvers to my GraphQL schema. Maybe you could go into more detail on the issues you’ve faced here so I can improve the project?
- Rotareti 8y agoI think it's worth mentioning, that the creator of Django REST framework is also working on Starlette [0], which is a modular framework that comes with async support, crazy performance, and more... [0]: https://www.starlette.io/ https://www.starlette.io/
- jplayer01 8y agoWhat would something like Starlette be used for?