A reminder of the settings and commands you need to get started with Django
django-admin startproject [project-name] .
[project-name]/settings.py
TIME_ZONE = 'Asia/Tokyo'
LANGUAGE_CODE = 'ja'
#When publishing a static file
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
#Add public host
ALLOWED_HOSTS = ['127.0.0.1', [host]]
##Example
ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com']
python manage.py migrate
python manage.py runserver [host]:[port]
python manage.py startapp [app-name]
[project-name]/settings.py
INSTALLED_APPS = [
...
'blog.apps.BlogConfig', #App class name of the added app
]
python manage.py makemigrations [app-name]
python manage.py migrate [app-name]
http://[host]:[port]/admin
python manage.py createsuperuser
.gitignore Base uses https://www.gitignore.io
.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
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
##Customize from here
# My pipenv
myvenv/
#VS code
.vscode/
##Customize up to here
# End of https://www.gitignore.io/api/django
Recommended Posts