Over the next few times, I'll be using Django to create a shogi game record management app!
First of all, the first language I learned in earnest was Python, and I wanted to create something using it. That was when I thought, "I wish I could manage the game record of my game history," for my hobby, shogi.
So at first I used Flask to make it halfway, but when I heard the opinions of the people around me, I decided that "Django is definitely better!" And decided to remake it from scratch.
Here, I will spell out the work process as it is, including memorandums, so thank you.
The working environment this time is as follows
--Creating a virtual environment in Anaconda --Django settings --Git settings for managing Django
I didn't know what Anaconda was in the first place (I put it in because I was told to put it in as an intern for ~~ 1day ~~). Therefore, I learned about Anaconda because it was described in detail in the following article. [[For beginners] Try creating a virtual environment with Anaconda] 1
I also referred to the following sites, including the installation of Django. [[Anaconda + Django] Try developing a web application with Python. ] 2
This time, I created a virtual environment called kifu_app.
$ anaconda -V
anaconda Command line client (version 1.7.2)
$ activate kifu_app
(kifu_app) $ python -V
Python 3.7.6
It was easy to finish by referring to [the previous blog] 2.
I referred to the following article. [Master Django fastest part1] 3
Navigate to the directory where you want to create the project and type:
$ django-admin startproject kifu_app
You now have a project with the following directory structure!
- kifu_app_project/
- kifu_app_project/
- setting.py
- urls.py
- wsgi.py
- __init__.py
- manage.py
In the upper kifu_app_project directory, do the following:
$ python manage.py startapp kifu_app
Then the directory structure will be as follows.
- kifu_app_project/
- kifu_app_project/
- setting.py
- urls.py
- wsgi.py
- __init__.py
- manage.py
- kifu_app
- admin.py
- apps.py
- migrations
- models.py
- tests.py
- views.py
- __init__.py
Finally, add the following to setting.py: (It seems that it is a report that I made an app!)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'kifu_app', # <-Add this
]
Anyway, I will make Git available after practice. This is also named kifu_app_project and I created a remote repository on GitHub.
For details such as commit, I referred to the following article. [How to use Django-Deployment ①-] 4
First, create a .gitignore file in kifu_app_project at the upper level. .gitignore removes specified files from tracking.
.gitignore
# Created by https://www.gitignore.io/api/django
# Edit at https://www.gitignore.io/?templates=django
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
media
A site called [gitignore.io] 5 will create a template for what you should write in .gitignore.
When you're ready, make your first commit.
$ git init
Initialized empty Git repository in ~/djangogirls/.git/
$ git config --global user.name "Registered user name on Github"
$ git config --global user.email Github registered email address
$ git add --all .
$ git commit -m "My Django Girls app, first commit"
13 files changed, ~~~
$git remote add origin repository URL
$ git remote -v
origin repository URL
$ git push -u origin master
It's okay if you execute the commands in order from the top. There are other people who explain in detail, so please refer to that.
When I checked GitHub, it was definitely pushed!
Next time, we will go to [Database Settings] 6!