Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

cckcoder/djackets

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo List

Django Side

  1. Install and setup (Django)

    1. pip install django
    2. pip install django-rest-framework
    3. pip install django-cors-headers
    4. pip install djoser
    5. pip install pillow
  2. Setup settings.py install REST

INSTALLED_APPS = [
    'rest_framework',
    'rest_framework.authtoken',
    'corsheaders',
    'djoser',
]
  1. Then config urls
urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include('djoser.urls')),
    path('api/v1/', include('djoser.urls.authtoken')),
]
  1. makemigration python3 manage.py makemigration
  2. migrate python3 manage.py migrate
  3. create super user python3 manage.py createsuperuser
  4. create product app python manage.py startapp product

Vue Side

  1. Install and setup (Vue) npm install -g @vue/cli

    1. create project with vue vue create djackets_vue
  2. Include Font Awesome

  3. Set up the base template

  4. Create django app and models for products

  5. Create serializer and views for the products

  6. Create simple front page (latest products)

  7. View a product

    1. Create viewset in Django
    2. Create vue page for showing product
    3. Add link to detail page
  8. Setup opp Vuex / State

  9. tools

    1. npm install bulma-toast

Reference

https://github.com/SteinOveHelset/djackets_vue

Server Setup (DigitalOcean)

  1. sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx

  2. sudo apt install certbot python3-certbot-nginx

  3. setup postgresql

    1. sudo -u postgres psql
    2. create database CREATE DATABASE djackets;
    3. create user CREATE USER djacketsuser WITH PASSWORD 'djacketspassword';
    4. set encoding to utf8 ALTER ROLE djacketsuser SET client_encoding TO 'utf8';
    5. set up grant for user GRANT ALL PRIVILEGES ON DATABASE djackets TO djacketsuser;
    6. quit pgsql shell \q
  4. setup python env

    1. sudo -H pip3 install --upgrade pip
    2. sudo -H pip3 install virtualenv
  5. create project directory

    1. mkdir -p /webapps/djackets
  6. create user group

    1. sudo groupadd --system webapps
  7. add user

    1. sudo useradd --system --gid webapps --shell /bin/bash --home /webapps/djackets djackets
  8. install pgsql python lib

    1. pip install psycopg2-binary
  9. set permission chown -R djackets:webapps .

  10. separate setting and manage for production

  11. install gunicorn pip install gunicorn

  12. config gunicorn

    1. vi env/bin/gunicorn_start

    2. `bash #!/bin/sh

      NAME='djackets_django' DJANGODIR=/webapps/djackets/djackets_django SOCKFILE=/webapps/djackets/env/run/gunicorn.sock USER=djackets GROUP=webapps NUM_WORKERS=3 DJANGO_SETTINGS_MODULE=djackets_django.setting_production DJANGO_WSGI_MODULE=djackets_django.wsgi TIMEOUT=120

      cd $DJANGODIR source ../env/bin/activate export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE export PYTHONPATH=$DJANGODIR:$PYTHONPATH

      RUNDIR=$(dirname $SOCKFILE) test -d $RUNDIR || mkdir -p $RUNDIR

      exec ../env/bin/gunicorn ${DJANGO_WSGI_MODULE}:application
      --name $NAME
      --workers $NUM_WORKERS
      --timeout $TIMEOUT
      --user=$USER --group=$GROUP
      --bind=unix:$SOCKFILE
      --log-level=debug
      --log-file=- `

    3. install supervisor apt install supervisor

    4. then cd /etc/supervisor/conf.d

    5. create file djackets.conf

    6. create supervisor log at env/logs

  13. setup supervisor

    1. use supervisorctl reread to read djackets.conf
    2. then supervisorctl update to add djackets.conf
    3. then supervisorctl status to check djackets.conf is working
  14. config NGINX

    1. go to dir cd /etc/nginx/sites-available
    2. create config file vi apidjackets.codewizz.org
    3. go to dir /etc/nginx/sites-enabled/
    4. make symbol link our config ln -s ../sites-available/apidjackets.codewizz.org .
    5. then service nginx restart

About

workshop vue and django build ecommerce website

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.