django default settings

Initial settings when developing with django

I can't remember it easily using django, so I'll leave it as a memorandum. The environment is created on the assumption that it is a Mac.

Creating a project

First, create a project. Take sampleproject as an example.

 django-admin startproject sampleproject .

Next, create the app. Let's take sample app as an example.

 python3 manage.py  startapp sampleapp 

Edit settings

Create a folder template to store the html file. The location to create is the same hierarchy as manage.py.

 mkdir template

Modify setting.py settings

setting.py


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'sampleapp'
]

Next, set the location of the template folder in setting.py. Describe BASE_DIR and'template'in [] of'DIRS' :.

setting.py


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR, 'template'],
        'APP_DIRS': True,
        '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',
            ],
        },
    },
]

We will add it gradually.

Recommended Posts

django default settings
Django + MySQL settings
Django URL settings
Django command completion settings
Django
DEBUG settings when using Django
django timezone and language settings
Django static file (static) related settings summary
django update
Django note 4
Django memorandum
Create a shogi game record management app using Django 3 ~ Django default management site settings ~
django search
samba settings
Django Summary
Django test
Django # 2 (template)
Django Note 5
Django hands-on
Touch django
django notes
Django Summary
Django basics
Django: Implement reusable APP settings following Django RestFrameWork
Django Shoho
Django defaults
Django + Docker
Django Glossary
Django search
Install Django
Django Project HTTPS Server Settings: Let's Encrypt
Django: References
VIM settings
[Django] Settings for sending emails using postfix
Django Note 1
Django note 3
Django note 2
Django startup
Django notes
Django NullCharField
[Django3] Environment construction and various settings summary [Python3]
Create initial settings and staff apps in Django
[Django] About static file related settings (images, videos)
DJango Memo: From the beginning (Error screen settings)
[Django] About static file related settings (css, js)