Very important commands for work with Django framework (python)

virtualenv -p /usr/bin/python3 env # create virtual env
source env/bin/activate # start env
deactivate # deactivate env

pip freeze # see instaled packages
pip freeze > requirements.txt # save your packages to txt file
pip install -U -r requirements.txt  # install all packages from txt file
pip install name_package # install some package

django-admin startproject name_your_project # install django folder with its structure

python ./manage.py makemigrations # create makemigrations
python ./manage.py migrate # add table to db
python manage.py showmigrations
python manage.py collectstatic

If you have problems with migrations:
python manage.py migrate --fake-initial
python manage.py migrate --run-syncdb

python ./manage.py createsuperuser # create root user

python manage.py startapp your_name_modul

python manage.py runserver # standard server startup
python manage.py runserver --insecure # start with DEBAG = False for working static files

Work with gunicorn:
gunicorn --bind 0.0.0.0:8000 your_name_project.wsgi # start
sudo systemctl start gunicorn.socket gunicorn.service
sudo systemctl status gunicorn
sudo systemctl restart gunicorn
sudo systemctl daemon-reload
sudo systemctl restart gunicorn.socket gunicorn.service

Work with server:
/etc/init.d/postgresql restart
/etc/init.d/nginx restart

Comments

Post a Comment