django-vue-template
django-vue-template copied to clipboard
What's the point of the index view?
trafficstars
As far as I can tell the index URL path doesn't do anything.
# Serve Vue Application
index_view = never_cache(TemplateView.as_view(template_name='index.html'))
# http://localhost:8000/
path('', index_view, name='index'),
This tells the template render engine to serve index.html from your configured directory.
Settings.py
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['dist'], # Add dist to dirs so Django looks for templates in /dist
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
So when deploying, your build script will put index.html in /dist which mounts your application & Django will see this as a template and serve it when / route is hit.