[Answer]-Sharing of various Django setup guides

1👍

This is a difficult question to answer because its more about opinions than anything else; and everyone works a different way. However, if you understand the reason behind the recommendations, then you will be better prepared to judge other bootstrapping scripts and – even better – build your own that does what you want.

Here are things you need to ensure are taken care of.

  1. Isolate your development packages from your system-wide Python install. Use virtual environments to accomplish this. Further, you should make sure you pin your packages so that you don’t get surprises when versions are upgraded.

  2. Use any form of version control. It doesn’t have to be git. You don’t need to use github.com. Use mercurial, cvs, bazaar or whatever else. The important part is you use something. So find out what works for you and get going.

  3. For development, do not even bother with a web server. Django comes with a webserver that you should use during development. Run it with python manage.py runserver. When you are finished with your development, you should deploy any web server that supports wsgi. The documentation provides deployment guides that can help you with this.

  4. Everyone and their dog has a recommendation for folder layout and structure. The problem is, each have their own reasons for recommending it. If you do not understand why you will only get frustrated with the layout. So, my suggestion is start with the standard layout that comes with django. The only thing I would add is that you create a docs/ directory where you stick any/all documentation for your project; and a requirements/ directory where you save all your requirements files and keep both of those updated.

Finally, some of my suggestions.

  1. Use postgresql unless you have a compelling reason to go with mysql. postgresql works best with django and some ORM features (like using distinct on columns) only work with postgresql.

  2. Keep your templates and views simple. Instead of cramming a lot of logic in the views, create other python modules that you can import. This will make your project easy to extend (for example, if you want to create an API). Your templates should have absolutely the minimal amount of logic. If you use custom template tags, make them as simple as possible because they are difficult to debug.

  3. Don’t be afraid of creating custom model managers and other tricks in the ORM. There is a lot of stuff you can do there that will make your application easier to develop.

  4. django-south is recommended, but make sure you understand how it impacts your projects before you install it; otherwise you’ll just end up after a few iterations with a migration that won’t run – then you’ll either spend a good amount of your time trying to fix the migrations, or simply dropping the database and starting over.

0👍

Found this great resource which was almost exactly what I am looking for.

epicserv updated 2013

https://gist.github.com/epicserve/1332256 (updated 2013)

senko updated 2011

http://senko.net/en/django-nginx-gunicorn/

👤laycat

Leave a comment