Issue
I have a Django backend and an Angular frontend.
I am using a package called django-invitations. When a user receives an invitation in an email they click on it and are taken to the app. django-invitations requires this line in settings.py
INVITATIONS_SIGNUP_REDIRECT = 'register'
This is the name of a route and reverse match is used to determine where to go.
The problem is I want the user to be taken to my sign-up page which is
http://example.com/#/registration
This is an Angular route.
My urls.py contains this line
url(r'^register', TemplateView.as_view(template_name='index.html'), name='register'),
This however takes the user to my index page and the url becomes
http://example.com/registration#/
How do I route a request from my Django backend to an Angular route with hash notation?
Solution
Got it!
Changed the line in urls.py to
url(r'^register/', views.redirect_to_register, name='register'),
Added a views.py
from django.shortcuts import render
from django.shortcuts import redirect
def redirect_to_register(request):
return redirect('/#/register')
And it works.
Answered By – Fauzan Raza
Answer Checked By – Katrina (AngularFixing Volunteer)