3 ms·
I had to double check the title because I thought he said Django and all the advice seemed to match my Rails experience and not my Django one, also, this may be
by overshard 13y ago
I had to double check the title because I thought he said Django and all the advice seemed to match my Rails experience and not my Django one, also, this may be a bit nitpicky, but Django isn't really an MVC Framework nor is it a CMS. You can only really call it a web framework as it has elements of these items but isn't the same:
1. The right directory structure, the default use for the media folder is supposed to be using for stuff uploaded through your app, not the files you develop, your static files should go in static and your compressed files should go in media as they are dynamically generated or in your global "static" folder that is pointed to from your web server. You should also have different settings.py files on a per-situation basis. Your development servers, staging, and production environments will probably all have different settings because at the very least development will have `DEBUG = True` and production `DEBUG = False`.
2. This is fine even though it seems wonky to use it for cron jobs to me.
3. This is fine too but I personally use nginx+uwsgi w/ emperor mode.
4. Up to you on this one, there are some nice Django branches that support key-value store databases but don't use the standard Django with key-value databases because it is 100% built around RDBMS.
5. Only piece of advice I agree with completely.
6. As partially discussed in #1 by me. I don't like his override method. I think an import of a base settings into production.py and development.py is cleaner.
7. Supervisor is good here but also if you use uwsgi in emperor mode instead of the suggested gunicorn it can handle the same task saving you an extra install and configuration.
8. Django very clearly has a nice Mixin for JSON responses in the docs or you can build a nice easy API using Tastypie: https://docs.djangoproject.com/en/1.5/topics/class-based-views/mixins/#more-than-just-html https://docs.djangoproject.com/en/1.5/topics/class-based-vie...
9. It's up to you if you want to use Redis, I don't personally need it for all the suggested things and I like how well memcached works with Django out of the box for caching.
10. Munin is great! I'm often too lazy to set it up and am fine reading log files.
11. This drove me to write this long comment... I actually get really annoyed when people try to mix in items from other stacks when there are many solid solutions already that don't force you to install another entire stack. Django has django_compressor which works great in this situation (https://github.com/jezdez/django_compressor https://github.com/jezdez/django_compressor) and a quick Google search will find many other similar solutions that won't require you to install Ruby to work with your Python web app.
Source: 6 years of developing Django apps and doing everything that was suggested here and more.
- xaritas 13y agoThe guy who wrote django-compressor fairly recently released a library to address the settings.py problem, django-configurations https://django-configurations.readthedocs.org/en/latest/ https://django-configurations.readthedocs.org/en/latest/ It uses classes to define your settings, and you can use inheritance to override and mixins to augment your bits of configuration. I usually have a "CommonSettings" class, with a few others extending it (Production, Development, etc.). At runtime the correct class is set based on an environment variable (you have to add a line or two to manage.py and wsgi.py to start the magic). Anyway, it doesn't seem that popular but I've enjoyed using it (and done so without problem).
- akoumjian 13y agoHow is Django not an MVC framework? I'm not being snarky, just curious.
- steveklabnik 13y agoMVC means a ton of different things. Django itself does not use "MVC" to describe itself: https://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names https://docs.djangoproject.com/en/dev/faq/general/#django-ap... > If you’re hungry for acronyms, you might say that Django is a “MTV” framework – that is, “model”, “template”, and “view.” That breakdown makes much more sense.
- misiti3780 13y agomodels -> models.py, controllers -> views.py, views -> templates, right?
- kitanata 13y agoIt's all semantics. As a long time django developer (4 years) I agree.