By Emmanuelle Delescolle
Naomi Cerder
The Django community
Daniele Procida & the team of volunteers
???
.
├── core
│ ├── admin.py
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── manage.py
├── other_app
│ ├── admin.py
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
└── project
├── __init__.py
├── __pycache__
├── settings.py
├── urls.py
└── wsgi.py
Mark Lavin: Anatomy of a Django Project
Django project is not a thing
project
├── environ.py.dist
├── manage.py
├── project
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ └── wsgi.py
├── requirements.txt
├── settings.py
└── urls.py
INSTALLED_APPS = (
'project',
'django.contrib.admin',
...
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
'loaders': (
'django.template.loaders.app_directories.Loader',
),
},
},
]
$ hg clone https://bitbucket.org/levit_scs/django_project_template
$ django-admin startproject --template
django_project_template/project_app/ project
$ django-admin startproject --template
django_project_template/drf_app/ project
$ django-admin startproject --template
django_project_template/reusable_app/ project
django_project_template/project_app
├── environ.py.dist
├── manage.py
├── project_name
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ └── wsgi.py
├── requirements.txt
├── settings.py
└── urls.py
"""
Django settings for {{ project_name }} project.
For more information on this file, see
https://docs.djangoproject.com/en/{{ docs_version }}/
topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/{{ docs_version }}/ref/
settings/
"""
Only python source files are templatable by default
cookiecutter by audreyr and pydanny
$ cookiecutter django_project_template/cc_project_app/
project_name (default is "Project name")? My great project
repo_name (default is "my_great_project")?
author (default is "Your Name")? Emma
my_great_project/
├── environ.py.dist
├── LICENSE.txt
├── manage.py
├── my_great_project
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ └── wsgi.py
├── README.md
├── requirements.txt
├── settings.py
└── urls.py
$ cat README.md
# Emma's My great project
Project description goes here
django_project_template/cc_project_app
├── cookiecutter.json
└── {{cookiecutter.repo_name}}
├── {{cookiecutter.repo_name}}
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ └── wsgi.py
├── environ.py.dist
├── LICENSE.txt
├── manage.py
├── README.md
├── requirements.txt
├── settings.py
└── urls.py
/* django_project_template/cc_project_app/cookiecutter.json */
{
"project_name": "Project name",
"repo_name":
"{{ cookiecutter.project_name|replace(' ', '_')|lower() }}",
"author": "Your Name"
}
#!/bin/bash
USER="{{ cookiecutter.username }}"
EMAIL="{{ cookiecutter.email }}"
virtualenv -p {{ cookiecutter.python }} venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
cp environ.py.dist environ.py
python manage.py migrate --noinput
echo "Creating superuper {{ cookiecutter.username }}"
python manage.py createsuperuser --username {{ cookiecutter.username }} --email {{ cookiecutter.email }}
wget https://github.com/twbs/bootstrap-sass/archive/v{{ cookiecutter.bootstrap_version }}.tar.gz
tar -xzf v{{ cookiecutter.bootstrap_version }}.tar.gz
mkdir -p {{ cookiecutter.repo_name}}/static/js
mv bootstrap-sass-{{ cookiecutter.bootstrap_version }}/assets/javascripts/* {{ cookiecutter.repo_name}}/static/js/
mv bootstrap-sass-{{ cookiecutter.bootstrap_version }}/assets/fonts {{ cookiecutter.repo_name}}/static/
mv bootstrap-sass-{{ cookiecutter.bootstrap_version }}/assets/stylesheets/* sass/css/
rm v{{ cookiecutter.bootstrap_version }}.tar.gz
rm -rf bootstrap-sass-{{ cookiecutter.bootstrap_version }}
wget -O {{ cookiecutter.repo_name }}/static/js/jquery.min.js http://code.jquery.com/jquery-{{ cookiecutter.jquery_version}}.min.js