(One of the summaries of a talk at the 2015 Djangocon EU conference).
Emmanuelle Delescolle says the django community is quite welcoming and friendly. The increased effort that is being poured into diversity is great.
She showed a sample django project filesystem structure. It looked like a bit of a mess. Not too standard. Then she showed the structure that has her preference, including the settings that belong to it.
Well, once you’re happy with such a structure, how can you use it all the time? Django now allows you to pass a template parameter to “startproject”. Then your template gets used instead of the standard django one:
$ django-admin startproject --template your-preferred_template/
You could make one for your reusable apps you want to release as open source. Automatically include a license file, for instance.
See the django docs .
How does such a template look? Basically the same as a regular django project,
only certain parameters get replaced. A folder project_name
gets renamed
in your project’s name, for instance. Same for python files: you can use {{
project_name }}
-like strings in there and they’ll get replaced.
But it is not enough. Only python files can be templated. Not other files that might also need it.
The solution is cookiecutter, which has many more possibilities. You can define questions to ask (like “author”, “project name”) and use those variables all over the place.
A cookiecutter template is a regular filesystem structure, just like with a
django project template. But the jinja-style {{ project_name }}
can now
also be used inside the filenames itself. Jinja filters can be used. And
variables can be replaced in any filetype.
There is a workshop on friday morning.
(Note: yes, use templates. I’m used to calling them skeletons. See an old blog post by me about it).
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):