[PYTHON] Djangos grundlegendes Memorandum

Ein Memorandum der notwendigen Einstellungen und Befehle zum Starten von Django

Projekterstellung

django-admin startproject [project-name] .

Einstellungen ändern

[project-name]/settings.py


TIME_ZONE = 'Asia/Tokyo'
LANGUAGE_CODE = 'ja'
#Beim Veröffentlichen einer statischen Datei
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
#Öffentlichen Host hinzufügen
ALLOWED_HOSTS = ['127.0.0.1', [host]]
##Beispiel
ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com']

Datenbankerstellung

python manage.py migrate

Webserver starten

python manage.py runserver [host]:[port]

Erstellen Sie eine neue Anwendung

python manage.py startapp [app-name]

Neue Anwendung zu den Einstellungen hinzufügen

[project-name]/settings.py



INSTALLED_APPS = [
    ...
    'blog.apps.BlogConfig', #App-Klassenname der hinzugefügten App
]

Erstellen Sie eine Migration, um eine Tabelle aus dem Modell zu erstellen

python manage.py makemigrations [app-name]

Ausführung der Migration

python manage.py migrate [app-name]

Zugriff auf den Verwaltungsbildschirm

http://[host]:[port]/admin

Super User erstellen

python manage.py createsuperuser

.gitignore Base verwendet 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/

##Von hier aus anpassen
# My pipenv
myvenv/

#VS code
.vscode/
##Anpassen bis hierher

# End of https://www.gitignore.io/api/django

Recommended Posts

Djangos grundlegendes Memorandum
Python Basic Memorandum Teil 2
Python Memorandum Super Basic
Arbeitsmemorandum (Pymongo) Teil 1. Grundlegende Bedienung
Matplotlib Memorandum
Linux Memorandum
jinja2 Memorandum
Numpy [Basic]
Python-Memorandum
Befehlsmemorandum
Python-Memorandum 2
Plotly Memorandum
Slackbot-Memorandum (1)
Memorandum MetaTrader5
Memorandum zu Djangos QueryDict
ShellScript-Memorandum
Pip Memorandum
Python-Memorandum
Grundlegende Befehle
Pydoc Memorandum
Python Memorandum
Memorandum of Pandas
Python Memorandum
DjangoGirls Memorandum
Befehlsmemorandum
Python-Memorandum
Pandas Memorandum
Python Memorandum
Djangos ImageField
Python-Memorandum
Memorandum für mich ③ Grundlegende Dateibearbeitung mit vi