Try using the Python web framework Django (2) --Look at setting.py

This is a continuation of Last time.

Directory structure

Looking at the project I made last time, the directory structure looks like this.

Initial commit for the time being

.gitignore did the following

db.sqlite3
manage.py
*.pyc

Initial commit.

$ git status
.gitignore
project/

$ git add .

$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   .gitignore
	new file:   project/__init__.py
	new file:   project/settings.py
	new file:   project/urls.py
	new file:   project/wsgi.py
	
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	project/__init__.pyc
	project/settings.pyc
	project/urls.pyc
	project/wsgi.pyc

$ git commit -m "initial commit"

I don't know how much to commit, such as __init__.py, but I committed everything for the time being. If it turns out to be inappropriate, fix it. (Honestly settings.pyc may not have been committed)

Take a look at setting.py

Database settings

The last command executed was

$ python manage.py migrate
$ python manage.py runserver

was. It seems that a pyc file is created for each py file depending on the timing of migrate or the timing of runsever. In addition, a sqlite file is created during migrate. Looking at setting.py,

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

There is a place called, and it seems that database migration will be done based on this. I will skip it for now.

Time zone setting

The time zone setting is the default

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

Since it is, I changed it as follows.

LANGUAGE_CODE = 'ja'

TIME_ZONE = 'Asia/Tokyo'

If you run server in this state and look at localhost: 8000, it will change to a Japanese page saying "It worked!".

Management page

You can access the administration page by accessing localhost: 8000 / admin with the server running, but I will omit it for now because I do not use it in particular.

Recommended Posts

Try using the Python web framework Django (2) --Look at setting.py
Try using the Python web framework Tornado Part 1
Try using the Python web framework Tornado Part 2
Try using the Python web framework Django (1)-From installation to server startup
Try using the web application framework Flask
(Python) Try to develop a web application using Django
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 1 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 2 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 3 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 4 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 5 ~
Try using the Python Cmd module
Install Python framework django using pip
Try using the Wunderlist API in Python
Try using the Kraken API in Python
How to build an application from the cloud using the Django web framework
Python web framework Django vs Pyramid vs Flask December 2015
Try using the BitFlyer Ligntning API in Python
Python: Try using the UI on Pythonista 3 on iPad
Try using the collections module (ChainMap) of python3
Try using the DropBox Core API in Python
Try Debian + Python 3.4 + django1.7 ...
Try using Django templates.html
Try using Tweepy [Python2.7]
Implement APIs at explosive speed using Django REST Framework
[Django Rest Framework] Customize the filter function using Django-Filter
Python Web framework performance comparison (Django, Flask, responder, FastAPI, japronto)
[Python] Try using Tkinter's canvas
Try using Kubernetes Client -Python-
A quick look at your profile within the django app
Try using the Twitter API
Try a similar search for Image Search using the Python SDK [Search]
Try using the Twitter API
Web scraping using Selenium (Python)
Try using the PeeringDB 2.0 API
Take a look at the Python built-in exception tree structure
Operate your browser using the Selenium Web Driver Python bindings
Get started with the Python framework Django on Mac OS X
Implementation of CRUD using REST API with Python + Django Rest framework + igGrid
I made a scaffolding tool for the Python web framework Bottle
Take a look at the built-in exception tree structure in Python 3.8.2
Visualize your pocket money files with the Python web framework Dash
Try using FireBase Cloud Firestore in Python for the time being
WEB application development using Django [Django startup]
WEB application development using Django [Application addition]
Try the Python LINE Pay SDK
Try using Pleasant's API (python / FastAPI)
Try using LevelDB in Python (plyvel)
Try Ajax on the Django page
Hit the web API in Python
Extract the targz file using python
Try using Python argparse's action API
Try using Leap Motion in Python
Try using Amazon DynamoDB from Python
Development and deployment of REST API in Python using Falcon Web Framework
[Mac] Build a Python 3.x environment at the fastest speed using Docker
I tried using "Streamlit" which can do the Web only with Python
Summarize the titles of Hottentori at the end and look at the present on the Web
Implement a simple application with Python full scratch without using a web framework.
Introducing the BOT framework Minette for Python
WEB application development using Django [Model definition]