This is the first trial for the reimplementation of my Django Family Library web app with a Django REST backend and an integrated Vue.JS template frontend.
- Python 3.7.3
- Django 2.2.10
- djangorestframework 3.10.2
- django-cors-headers 3.2.1
- djangorestframework-jwt .11.0
From inside the project's folder, and using your virtualenv of choice:
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
- Initialize:
- Create the new project:
django-admin startproject family-library-django-rest-vue
- Copy over folder for
library
django app - Add
library
toINSTALLED_APPS
insetting.py
- Create this
README
file - Install dependencies:
pip install djangorestframework django-filter
- Add
rest_framework
,rest_framework.authtoken
,django_filters
toINSTALLED_APPS
insetting.py
- Migrate models:
python manage.py migrate
- Create the new project:
- Creating:
- Add
library/serializers.py
and create serializer for each model class - Create
library/viewsets.py
- Create
library/renderers.py
to render model data to JSON - In the
/family-library-django-rest-vue/
subfolder:- Create
routers.py
- In
urls.py
importrouters.py
and include it inurlpatterns
- Create
- Add
- Test run:
python manage.py runserver
- Adapting
views.py
:- link up renderer and serializer for each view
- adapt
urls.py
to new views
- Create
library/templates/library/index.html
to hold the Vue app - Add
vuejs
imports toindex.html
- Register the new template view in
urls.py
- Add
Vue
constructor script to template - Add constructor elements:
delimiter
,el
,http
,methods
,mounted
- Create
CRUD
methods for models - Add function calls to
mounted
After a valid login, backend includes a HTML header called auth-token
with valid JWT value.
Vue grabs that value, and adds it as a header to every query