It's a basic structure which can serve as a base for your Django projects.
- Django 1.3
- Linux OS
- project - the source code
- contains all the Django custom applications and settings
- "project/apps" hosts the custom applications
- "project/settings" includes the settings for various environments.
- "project/settings/settings.py" is the file created by the "django-admin.py" tool, the rest of the settings file will import/extend this one.
- the code from "ipy_user_conf.py" will import all the models when one executes "python manage.py shell" and "ipython" is available
- "manage.py" must receive the "--settings" argument (please see the usage below)
- static - the Django's STATIC_ROOT directory
- media - the Django's MEDIA_ROOT directory
- env - virtualenv or buildout environment files
- help - files related to the project, tutorials, photoshop files, etc
- setup - files necessary to setup the project inside various environments
- logs - the logs
- database - this is the parent location of your sqlite database, if case
- all project files are placed under the same parent
- keep the project's files in a logical and easy to find structure
- isolate the environment files so they don't mix with the project
- easy to decide which directories are to be kept on GIT
- YUI reset and fonts CSS is being used
- a basic CSS file built with lesscss.org
- the base template is using a grid layout based on YUI Grids
- $ cd /project_name
- $ git clone [email protected]:florentin/django-skeleton.git .
- $ virtualenv env --no-site-packages
- $ source ./env/bin/activate
- $ mkdir -p database
- $ pip install -r ./setup/requirements/production.txt
- $ pip install -r ./setup/requirements/development.txt
- $ cd /project_name/
- $ source ./env/bin/activate
- $ python ./project/manage.py syncdb --settings=settings.development --noinput
- $ python ./project/manage.py createsuperuser --settings=settings.development --email=[email protected] --username=admin
- $ Password: admin
- $ cd /project_name/
- $ source ./env/bin/activate
- $ python ./project/manage.py runserver --settings=settings.development --nostatic
- or the hard way:
- $ export PYTHONPATH="./project:${PYTHONPATH}"; export PYTHONPATH="./project/apps:${PYTHONPATH}"; export DJANGO_SETTINGS_MODULE=settings.development; django-admin.py runserver --nostatic
You have probably noticed the long line needed to run the commands though the "manage.py". One solution is to create a bash function in .bash_aliases:
dj() { python ./project/manage.py $@ --settings=settings.development; }
Usage:
$ dj runserver --nostatic