Setting up project and application templates in django

I would like to configure files and folders created at startup

python manage.py startapp appname 

I find that I am doing something over and over again, and I think that it would be neat if my settings appear when I create a new application.

Do you know where I can configure the default files when creating the application?

+7
django
source share
4 answers

Files are located in django/conf/app_template and django/conf/project_template for application and project files respectively.

I don’t think there are ways to redefine this location without creating my own startapp / startproject or without modifying django/core/management/base.py

+5
source share

startapp and startproject accept the --template flag, with which you can specify the directory or compressed file that the team should use as a template for your new application or project. It is also passed in the context with your application / project name, which you can insert into your templates with template tags.

See https://docs.djangoproject.com/en/dev/ref/django-admin/#startapp-appname-destination for more details.

It looks like it was added in 1.4.

+6
source share

You can copy your customized files, and not create created without problems.

+2
source share

If you are using an older version of django, you can write your own django-admin command, as shown in the figure here . you can write a startapp modification that creates your custom files.

+2
source share

All Articles