Search code examples
pythondjangodirectory-structureproject-structure

python django project and folder structure (differing from WAMP)


I have my development environment setup on Win 7 like this:

Django development structure

Apache      -server-        C:\Program Files (x86)\Apache Software Foundation\Apache2.4
PostgreSQL  -database-      C:\Program Files\PostgreSQL\9.2
Django      -framework-     C:\Python27\Lib\site-packages\django
Python      -code-          C:\Python27
Project     -root-          C:\mysite
    |----------apps
    |----------HTML
    |----------CSS
    |----------JavaScript
    |----------assets

I am attempting to keep this extremely simple to start out. There are 5 main directories each with a distinct purpose. All the code resides in the project folder.

compared to WAMP structure:

C:\WAMP
    |----------C:\Apache
    |----------C:\MySQL
    |----------C:\PHP
    |----------C:\www

I like how Apache, MySQL, and PHP all reside in a neat directory. I know to keep the root project OUTSIDE in another directory in Django for security reasons.

  • Is it fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?
  • Did I miss a core Django component and/or directory?
  • Will deploying and scaling be a problem?

I want this to be a guideline for beginning Django web programmers.


Solution

  • I can answer the question one by one:

    • Is if fine that Apache, PostgreSQL, and Python are installed all over the place in the Django environment?

      All over the place sounds weird but yes it is totally fine.

    • Did I miss a core Django component and/or directory?

      No you don't miss anything, Django core is in site-packages folder already and your site code is mysite, which can be located anywhere you want.

    • Will deploying and scaling be a problem?

      No it won't be a problem with current structure. You will deploy your mysite only, the other will be installed separately.

    Something you should get familiar with when starting with Django development:

    • Most likely when you deploy your project, it will be on a Linux server, so install and learn Linux maybe?

    • virtualenv: Soon you will have to install Django, then a bunch of external packages to support your project. virtualenv helps you isolate your working environment. Well it's "unofficial" a must when you start with python development.

    • virtualenvwrapper to make your life easier when working with virtualenv

    • git and github or bitbucket: if you don't know git yet, you should now.