Skip to main content

Django RestFramework Swagger Master

Summary

  • Django
  • Django Environ
  • Django Template
  • Django RestFramework
  • Django RestFramework Swagger

Save your time and please PR if more feature for django template.

Environment

  1. Install Server Firewall

    sudo ufw enable sudo ufw allow ssh sudo ufw allow http sudo ufw allow https sudo ufw allow ftp sudo ufw status

  2. Install Python Environment

    sudo apt-get install python3-dev virtualenv

  3. Install Database Service Mysql

    • install

    sudo apt-get install build-essential mysql-server libmysqlclient-dev

    • service

    sudo ufw allow mysql sudo systemctl start mysql sudo systemctl enable mysql

    • setting root user

    sudo -u root mysql

    USE mysql; UPDATE user SET authentication_string=PASSWORD("rootpassword") WHERE User='root'; UPDATE user SET plugin="mysql_native_password"; FLUSH PRIVILEGES; exit

    • setting new user

    CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword'; GRANT ALL PRIVILEGES ON . TO 'myuser'@'localhost'; FLUSH PRIVILEGES; exit

    mysql -u myuser -p

    CREATE DATABASE mydb;

    Postgresql

    • install

    sudo apt-get install libpq-dev postgresql postgresql-contrib

    • service

    sudo ufw allow postgresql sudo systemctl start postgresql sudo systemctl enable postgresql

    • setting root user

    sudo -u postgres psql \password sde \q

    • setting new user

    CREATE DATABASE mydb;

    CREATE USER myuser WITH PASSWORD 'mypassword'; ALTER ROLE myuser SET client_encoding TO 'utf8'; ALTER ROLE myuser SET default_transaction_isolation TO 'read committed'; ALTER ROLE myuser SET timezone TO 'UTC'; GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;

Installation

  1. Install Django Project

    • setting secret key

    mv mysite/_secret_settings.py mysite/secret_settings.py nano mysite/secret_settings.py

    • install virtual environment

    virtualenv -p python3 venv source venv/bin/activate

    • install django project

    pip install -r requirement.txt python manage.py makemigrations python manage.py migrate python manage.py createsuperuser python manage.py collectstatic

    • testing django project

    sudo ufw allow 8000 python manage.py runserver 0:8000

Deployment

  1. Install Gunicorn

    pip install gunicorn gunicorn --bind 0.0.0.0:8000 mysite.wsgi

    sudo nano /etc/systemd/system/gunicorn.service

    [Unit]
    Description=gunicorn daemon
    After=network.target
    
    [Service]
    User=ubuntu
    Group=www-data
    WorkingDirectory=/home/ubuntu/mysite
    ExecStart=/home/ubuntu/django-rest-swagger-master/mysite/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/mysite/mysite.sock mysite.wsgi:application
    
    [Install]
    WantedBy=multi-user.target
    

    sudo systemctl restart gunicorn sudo systemctl enable gunicorn

  2. Install Nginx

    sudo apt-get install nginx sudo nano /etc/nginx/sites-available/mysite

    server {
        listen 80;
        server_name server_domain_or_IP;
    
        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/ubuntu/django-rest-swagger-master;
        }
        location /static/ {
            root /home/ubuntu/django-rest-swagger-master;
        }
    
        location / {
            include proxy_params;
            proxy_pass http://unix:/home/ubuntu/django-rest-swagger-master/mysite.sock;
        }
    }
    

    sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled sudo nginx -t sudo systemctl restart nginx sudo ufw allow 'Nginx Full'

Metadata

Release files for django-rest-swagger-master 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-rest-swagger-master 1.0.5
File Size Uploaded
django-rest-swagger-master-1.0.5.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-rest-swagger-master 1.0.5
File Interpreter ABI Platform
django_rest_swagger_master-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / django-rest-swagger-master-1.0.5.tar.gz

Download URL django-rest-swagger-master-1.0.5.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
54785598a78099e60d41c9ffb69c1a29d6f228d65a52068698f7c4fadd85e877
BLAKE2b-256 checksum
How to use checksums
aae525057f04c95eec055071b1af35d5a6933549d6c6d0a85024e820e5343fde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

Release files / django_rest_swagger_master-1.0.5-py3-none-any.whl

Download URL django_rest_swagger_master-1.0.5-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e78dbd5eb1f7b3d2a324c0aa00d66522c8a32b08e9119cbb568b34b6bde7af90
BLAKE2b-256 checksum
How to use checksums
61756b2331fdf02a5c21da4c23cd0ebed52b085e1e794d1c021a8b333de8b195
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page