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.pyand addurl.pycontent 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.pyIn 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.gitDesign Ideas
- Use cookiecutter to generate project structure, including custom
settings.pyfile. All apps should be placed in the apps folder. - 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- After creating apps, you can test if apps work properly.
python manage.py runserverVisit http://127.0.0.1:8000/app1/
hello app1
Usage Suggestions
- Users should fork this repository, clone it locally, and then make modifications. Such as time zone settings, database settings, email settings in
settings.py. - Users can modify the
cookiecutter.jsonfile to customize the project configuration. - 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.
- Users can extend the
add_app.pyfile under the generated project to perform custom operations when creating apps.
If you have good suggestions, please submit an issue