Todo loyihasi uchun djangoda yozilgan rest api
Python [3.6, 3.7, 3.8, 3.9 va 3.10]. Tavfsiya qilinadigan versiya: 3.10
python -m venv venv
Har safar terminalni qayta ochganda virtual muhitni aktivlashtirish kerak
source venv/bin/activate
cmd.exe
venv\Scripts\activate.bat
PowerShell
venv\Scripts\activate.ps1
Kerakli paketlarni o'rnatish uchun pip paket menejeridan foydalaning.
pip install -r requirements.txt
python manage.py migrate
python manage.py runscript -v3 auto_configure
nano /etc/systemd/system/gunicorn_TodoAPI.socket
[Unit]
Description=TodoAPI gunicorn socket
[Socket]
ListenStream=/run/gunicorn_TodoAPI.sock
[Install]
WantedBy=sockets.target
and
nano /etc/systemd/system/gunicorn_TodoAPI.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn_TodoAPI.socket
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/ecs-user/TodoAPI
ExecStart=/home/ecs-user/TodoAPI/venv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn_TodoAPI.sock \
config.wsgi:application
[Install]
WantedBy=multi-user.target
and
# Save and close the file then set proper permission to the Django project directory
$ chown -R www-data:ecs-user ~/TodoAPI
# reload systemd daemon
$ systemctl daemon-reload
# start and enable gunicorn_TodoAPI service
$ systemctl start gunicorn_TodoAPI.service
$ systemctl enable gunicorn_TodoAPI.service
# check
$ systemctl status gunicorn_TodoAPI
# /etc/nginx/conf.d/TodoAPI.conf
# This configuration will be changed to redirect to HTTPS later
server {
server_name server_adress;
listen 80;
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn_TodoAPI.sock;
}
}
Setup
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo systemctl restart nginx
python manage.py runserver
Admin panelga kirish uchun superuser ma'lumotlari
username = superuser
password = superuser
GoogleOauth2.md ga qarang