-
Install and setup (Django)
pip install djangopip install django-rest-frameworkpip install django-cors-headerspip install djoserpip install pillow
-
Setup settings.py install REST
INSTALLED_APPS = [
'rest_framework',
'rest_framework.authtoken',
'corsheaders',
'djoser',
]- Then config urls
urlpatterns = [
path('admin/', admin.site.urls),
path('api/v1/', include('djoser.urls')),
path('api/v1/', include('djoser.urls.authtoken')),
]- makemigration
python3 manage.py makemigration - migrate
python3 manage.py migrate - create super user
python3 manage.py createsuperuser - create product app
python manage.py startapp product
-
Install and setup (Vue)
npm install -g @vue/cli- create project with vue
vue create djackets_vue
- create project with vue
-
Include Font Awesome
-
Set up the base template
-
Create django app and models for products
-
Create serializer and views for the products
-
Create simple front page (latest products)
-
View a product
- Create viewset in Django
- Create vue page for showing product
- Add link to detail page
-
Setup opp Vuex / State
-
tools
npm install bulma-toast
https://github.com/SteinOveHelset/djackets_vue
-
sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx -
sudo apt install certbot python3-certbot-nginx -
setup postgresql
sudo -u postgres psql- create database
CREATE DATABASE djackets; - create user
CREATE USER djacketsuser WITH PASSWORD 'djacketspassword'; - set encoding to utf8
ALTER ROLE djacketsuser SET client_encoding TO 'utf8'; - set up grant for user
GRANT ALL PRIVILEGES ON DATABASE djackets TO djacketsuser; - quit pgsql shell
\q
-
setup python env
sudo -H pip3 install --upgrade pipsudo -H pip3 install virtualenv
-
create project directory
mkdir -p /webapps/djackets
-
create user group
sudo groupadd --system webapps
-
add user
sudo useradd --system --gid webapps --shell /bin/bash --home /webapps/djackets djackets
-
install pgsql python lib
pip install psycopg2-binary
-
set permission
chown -R djackets:webapps . -
separate setting and manage for production
-
install gunicorn
pip install gunicorn -
config gunicorn
-
vi env/bin/gunicorn_start -
`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=- ` -
install supervisor
apt install supervisor -
then
cd /etc/supervisor/conf.d -
create file djackets.conf
-
create supervisor log at env/logs
-
-
setup supervisor
- use
supervisorctl rereadto read djackets.conf - then
supervisorctl updateto add djackets.conf - then
supervisorctl statusto check djackets.conf is working
- use
-
config NGINX
- go to dir
cd /etc/nginx/sites-available - create config file
vi apidjackets.codewizz.org - go to dir
/etc/nginx/sites-enabled/ - make symbol link our config
ln -s ../sites-available/apidjackets.codewizz.org . - then
service nginx restart
- go to dir