Skip to content

Lightweight Django Cookiecutter Template

This project uses cookiecutter to create projects. It can batch create Django apps. After using python manage.py startapp <app_name>, you usually need to do the following configuration work:

  • Add app in settings.py
  • Create urls.py and add url.py content to project_name/urls.py
  • Create templates\app_name folder. You may need to create index.html file
  • Add default index method in views.py
  • Other possible configurations, such as admin.py In this process, it is easy to make mistakes. Therefore, we need an automated method for configuration.

Background Knowledge

When using this project, users are expected to have background knowledge of cookiecutter and Django. The official template django-cookiecutter is too heavy. Web projects generally do not need to be so complex. So I customized a lightweight template.

GitHub Address

moomboss cookiecutter The project's Readme explains how to install and use the template.

cookiecutter git@github.com:silentQQQ/cookiecutter.git

Design Ideas

  1. Use cookiecutter to generate project structure, including custom settings.py file. All apps should be placed in the apps folder.
  2. After creating the project, use add_app.py under the project to batch create apps. This script completes the manual operations mentioned at the beginning of the article.
python add_app.py app1 app2 app3
  1. After creating apps, you can test if apps work properly.
  python manage.py runserver

Visit http://127.0.0.1:8000/app1/

hello app1

Usage Suggestions

  1. Users should fork this repository, clone it locally, and then make modifications. Such as time zone settings, database settings, email settings in settings.py.
  2. Users can modify the cookiecutter.json file to customize the project configuration.
  3. Users can modify \hooks\pre_gen_project.py and post_gen_project.py. These are hook functions before and after cookiecutter creates projects. They can do custom operations.
  4. Users can extend the add_app.py file under the generated project to perform custom operations when creating apps.

If you have good suggestions, please submit an issue

Released under the [BY-NC-ND License](https://creativecommons.org/licenses/by-nc-nd/4.0/deed.en).