1

Trying to render vue js build (index.html) in Django its working fine but the problem is that when i give any route to that url than i get page not found from vue.

This working fine

url(r'^$', TemplateView.as_view(template_name="index.html"), name='whatever'),

And this is not, giving page not found error of vue

url(r'^website/', TemplateView.as_view(template_name="index.html"), name='whatever'),

enter image description here

4
  • How do you render your vue instance? Commented Jul 10, 2020 at 13:41
  • i am directly calling template of vue js in urls.py please check this url(r'^$', TemplateView.as_view(template_name="index.html"), name='whatever'), Commented Jul 10, 2020 at 13:46
  • Try url(r'^website/$', TemplateView.as_view(template_name="index.html"), name='whatever'), Commented Jul 10, 2020 at 13:53
  • Not working, still page not found:-( Commented Jul 10, 2020 at 14:33

1 Answer 1

1

Hi I got a solution to the problem you have to set the default route in your router to set it redirection to the specific path

code for your router.js in vue project

new Router({
  mode: 'History',
  base: '/app'
  routes: [
   {
     path: '/',
     name: 'name',
     component: ComponentName
   }
  ]
})

and also mention the same URL name in you API in Django

urlpatterns = [
  url(r'^admin/', admin.site.urls),
  url(r'^api-token-auth/', obtain_jwt_token),
  url(r'^.*$/app', views.home),
]

for more detailed conversation refer to this answer

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.