🗺 rixx.de · 🐦 @rixxtr · 🐘 @rixx@chaos.social
$ python ./manage.py help
Type 'manage.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[auth]
changepassword
createsuperuser
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
…
$ python manage.py migrate
Operations to perform:
Apply all migrations: auth, authtoken, contenttypes, myapp, sessions
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
media vs static
$ python ./manage.py collectstatic
You have requested to collect static files at the destination
location as specified in your settings:
/home/myproject/src/myproject/src/static.dist
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
496 static files copied to '/home/myproject/src/myproject/src/static.dist', 517 post-processed.
pip install --user
python -m venv
local_settings.py
settings.py
something.cfg
DEBUG = False
SECRET_KEY = 'skjdfölajfalskjfdsaölk…'
ALLOWED_HOSTS = ['example.org', '172.0.0.21']
DATABASES = {'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'myproject',
'USER': …
}}
STATIC_ROOT = '/var/www/project/static/'
MEDIA_ROOT = '/var/www/project/media/'
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = False
USE_X_FORWARDED_HOST = True
USE_X_FORWARDED_PORT = True
ADMINS = [
('Admin1', 'me@admin.org'),
('Admin2', 'me@example.org'),
]
EMAIL_HOST = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_HOST_USER = ''
EMAIL_PORT = 25
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
SERVER_EMAIL = 'sender@example.org'
LOGGING['handlers']['mail_admins'] = {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler',
}
pip install gunicorn
[Unit]
Requires=myproject.socket
After=network.target
[Service]
User=myproject
WorkingDirectory=/home/myproject/src
ExecStart=/home/myproject/.local/bin/gunicorn --bind unix:/run/gunicorn/myproject --workers 4 myproject.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
site-packages
pip install (--user) -U …
python ./manage.py migrate
python ./manage.py collectstatic
python ./manage.py compress
python ./manage.py compilemessages
python ./manage.py clearsessions