I have a Django 2 + Angular 6 project. I have a build process that moves my compiled JS files into the Django's static folder.
However, whenever I go to a link, say http://127.0.0.1:8000/#/upload, the browser always redirect me to http://127.0.0.1:8000/static/my_project/#/upload.. What is happening?
I'm using hash location strategy. My page still works, but whenever I refresh at the latter URL or visit it directly, I get an 404..
My urls.py
file is like this:
urlpatterns = [
path('', IndexView.as_view()),
path('admin/', admin.site.urls),
path('api/v1/', include(router.urls)),
]
The first url pattern matches an IndexView
, which is just a TemplateView
with this index.html
:
{% load static from staticfiles %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="{% static 'favicon.ico' %}">
</head>
<body>
<app-root></app-root>
<script type="text/javascript" src="{% static 'uploader/runtime.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/polyfills.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/styles.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/vendor.js' %}"></script>
<script type="text/javascript" src="{% static 'uploader/main.js' %}"></script>
</body>
</html>