angular setup for django (routes not working)

38 views
Skip to first unread message

nitish kumar

unread,
Dec 26, 2019, 8:05:14 AM12/26/19
to Django users
Hi 


I am trying to integrate angular8 with Django (2.2.4).


Django side:

URL and view will load angular 'index.html'

angular:

some router-links.
based on URL pattern page is getting loaded.


problem statement:

if host only angular code using 'ng serve' router-link only load's particular component instead of loading all links in the index.html file
but when I host in Django router-link is loading the entire page again (i can see this in developers tools network tab)

can some please help..

lemme smash

unread,
Dec 27, 2019, 10:20:42 AM12/27/19
to Django users
you doing something strange.
usually, when you want to setup angluar with django, you just using `ng serve` to handle all the interface, and just use django for data and api. it's not a good idea to render angular app with django

nitish kumar

unread,
Dec 29, 2019, 8:38:25 AM12/29/19
to Django users
we have a web app which is hosted in apache mod_wsgi.

I am trying to update some of the app functionality/UI with angular 8.

everything works of but angular routes are not working , which is important for single-page app

Andréas Kühne

unread,
Dec 30, 2019, 4:17:51 AM12/30/19
to django...@googlegroups.com
Hi,

You can't have the routes for the frontend and the backend. For example:

/clients/1/ in urls.py and in the angular routes. Then it all goes back to who gets the route first. 

For this example the frontend should have:
/clients/:id/

and the backend should:
/api/clients/id/

Regards,

Andréas


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/37f1e12f-c6fd-4f83-bb3e-086e05e7a801%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages