Home:ALL Converter>How do I setup and alternate directory structure for django?

How do I setup and alternate directory structure for django?

Ask Time:2011-11-10T06:01:37         Author:Kin

Json Formatter

I'm starting on my first large django project and have realized that the default directory structure isn't going to work well.

I saw this question and answer and decided to implement something similar. Large Django application layout

What do I need to do to make something like this work? How can I change where django looks for apps/modules?

Author:Kin,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/8072358/how-do-i-setup-and-alternate-directory-structure-for-django
Lycha :

Python works automatically with deep directory structures. That's porbably you didn't find any instructions on how to do it.Here are some instructions on how to get classes and models to work. \n\nIf you want to have a module in folder yourproject/apps/firstapp you can just add it to INSTALLED_APPS by adding line 'apps.firstapp',. You will have to add a __init__.py file to each of the directories so that they are recognized as python packages.\n\nWhen you import classes you can simply use from yourproject.apps.firstapp.filename import yourclass.\n\nYou should also make sure all template directories are listed in TEMPLATE_DIRS.",
2011-11-09T22:23:59
Jack M. :

I have two methods to handle this; one for production and one for development. \n\nIn development:\nAppend the path to your apps in your settings.py. In my case, I have my main project in ~/hg/django/project/ and my apps are in ~/hg/django/apps/. So I use:\n\nif DEVEL:\n sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'apps'))\n\n\nI also use the production method on my development box. This method has a knock on effect of letting me roll back to the most recent production version by simply commenting out the line path insertion in the settings.py.\n\nIn production:\nI install the apps using distutils so that I can control deployment per server, and multiple projects running on each server can all access them. You can read about the distutils setup scripts here. Then, to install, you simply:\n\n./setup.py install\n",
2011-11-09T22:22:35
yy