Skip to main content

Django Template with Template, Restframework and Swagger.

Project description

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'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-rest-swagger-master-1.0.5.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

django_rest_swagger_master-1.0.5-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file django-rest-swagger-master-1.0.5.tar.gz.

File metadata

  • Download URL: django-rest-swagger-master-1.0.5.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for django-rest-swagger-master-1.0.5.tar.gz
Algorithm Hash digest
SHA256 54785598a78099e60d41c9ffb69c1a29d6f228d65a52068698f7c4fadd85e877
MD5 6a96af721775f2e5412cfc02b8dc7525
BLAKE2b-256 aae525057f04c95eec055071b1af35d5a6933549d6c6d0a85024e820e5343fde

See more details on using hashes here.

File details

Details for the file django_rest_swagger_master-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: django_rest_swagger_master-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for django_rest_swagger_master-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e78dbd5eb1f7b3d2a324c0aa00d66522c8a32b08e9119cbb568b34b6bde7af90
MD5 3d66da1fe9b8079dc4691e050efb03e2
BLAKE2b-256 61756b2331fdf02a5c21da4c23cd0ebed52b085e1e794d1c021a8b333de8b195

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page