- Django
- Django Restframework
- Django Whitenoise
- Vue Cli 3
- Vue Router
Location | Content |
---|---|
/backend |
Django Project & Backend Config |
/backend/api |
Django App (/api ) |
/src |
Vue App . |
/src/main.js |
JS Application Entry Point |
/public/index.html |
Html Application Entry Point (/ ) |
/public/static |
Static Assets |
/dist/ |
Bundled Assets Output (generated at yarn build |
Before getting started you should have the following installed and running:
- Yarn - instructions
- Vue Cli 3 - instructions
- Python 3
- Pipenv
$ git clone https://github.com/FranBisquerra/django-vue.git
$ cd django-vue
Setup
$ yarn install
$ pipenv install --dev & pipenv shell
$ python manage.py runserver
From another tab in the same directory:
$ yarn serve
The Vuejs application will be served from localhost:8080
and the Django Api
and static files will be served from localhost:8000
.
The dual dev server setup allows you to take advantage of
webpack's development server with hot module replacement.
Proxy config in vue.config.js
is used to route the requests
back to django's Api on port 8000.
If you would rather run a single dev server, you can run Django's
development server only on :8000
, but you have to build the Vue app first
and the page will not reload on changes.
$ yarn build
$ python manage.py runserverd
See settings.dev
and vue.config.js
for notes on static assets strategy.
Implements the approach suggested by Whitenoise Django. For more details see WhiteNoise Documentation
It uses Django Whitenoise to serve all static files and Vue bundled files at /static/
.