Developed Directory Structure
Over the course of my web development life, I have changed my work flow and directory structure many times. Each time gets a little bit better, but I doubt I will ever finish modifying it, as I am always learning new techniques.
I am presently using Django in all of my projects, both at work and as a hobby. Django’s ability to easily reuse applications has mad me change my directory structure several time. Finally, I do believe I have settled.
First thing to know, is that both at work and in my pet projects, I am hosting multiple websites on the same apache instance. This is simply because the load behind the website does not justify buying a new slice (I use slicehost for my hosting needs).
So that being said, I need to have a directory structure capable of handling each one of my projects, all of my own shared applications, and all of the downloaded applications.
Here is what I have come up with.
– project 1/
—- non reusable app 1/
—- non reusable app 2/
– project 2/
– project 3/
—- non reusable app 3/
– self made reusable app 1/
– self made reusable app 2/
– grabbed reusable app 1/
– grabbed reusable app 2/
– grabbed reusable app 3/
Basically, the idea being that I store my projects in the projects folder, with applications made just for that project in the project’s application folder.
I put applications that I build that will be used by more than one project into the common folder.
Applications that I have grabbed from other people (comment_utils, tagging, etc) into the external folder.
Then for each virtual host, I add to the python path the projects folder, then reference settings by projectname.settings (from observation, django adds the folder where the settings file is to the python path itsself), and the common folder and the external folder. I also add the projects, external, and common folders to the python path inside of conf file.
That works for apache, but then to get manage.py to work (it doesn’t work because none of the python paths are set for it), I edit “/etc/environment” and add the line
Bingo, now manage.py works.
Now, any time I want to add a new project, I do not have a ton of hassle trying to get the project’s manage.py to work, and all my virtual hosts in apache have the same structure!