Thing is, I have an angular + cordova app on one module. I just want the REST api from django for the webserver. no views or anything (well only to serve the angular views).
How can I serve the static index.html using django? do I need different project structure? I'm a newbie to django.
Thanks in advance!
You can use TemplateView
directly:
from django.views.generic import TemplateView
...
url(r'^$', TemplateView.as_view(template_name='index.html'))
Remember you need to configure your templates folder to call .html
files by name only.
First, place this index.html page in your server/templates folder so Django knows about it.
Then, do this in your URLs.py:
from django.views.generic import TemplateView
urlpatterns = [
url(r'^$', TemplateView.as_view(template_name='index.html')),
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.