These are chat archives for owais/django-webpack-loader

21st
Oct 2015
liondancer
@liondancer
Oct 21 2015 09:08
I cant seem to get react-router working with django. Correct me if I'm wrong but I should be able to navigate my site after webpack builds everything? https://github.com/liondancer/django-cherngloong/
When I enter http://localhost:8000/contact (a react-router route) django wants to pick up that route and since it doesnt exists, it gives me server error... Page not found (404)
Owais Lone
@owais
Oct 21 2015 12:04
react-router has nothing to do with django
they are completely independent
liondancer
@liondancer
Oct 21 2015 16:37
Would you know what I am doing wrong?
I am trying to keep the two separate but
Owais Lone
@owais
Oct 21 2015 16:43

When I enter http://localhost:8000/contact (a react-router route) django wants to pick up that route and since it doesnt exists, it gives me server error... Page not found (404)

This is expected behaviour. You are using django serve the content and if a url doesn't exist, it'll naturally raise 404

Read about how django handles urls here: https://docs.djangoproject.com/en/1.8/topics/http/urls/
liondancer
@liondancer
Oct 21 2015 16:44
How can I have only the frontend serve the handle the URLS and have django as an API
Owais Lone
@owais
Oct 21 2015 18:49

Don't serve your app from django or make django to serve the same view on ANY url. If it pretty straightforward, e.g,

    url(r'', TemplateView.as_view(template_name='index.html')),

will serve index.html to any url

liondancer
@liondancer
Oct 21 2015 21:16
@owais it started working when the url regex is r'' but in the blog it was r'^$'
liondancer
@liondancer
Oct 21 2015 21:38
my pages show up empty but the developer tools states http://localhost:8000/static/public/js/main.js Failed to load resource: the server responded with a status of 404 (NOT FOUND)