HOW TO REDIRECT DIFFERENT CATEGORY OF USERS THROUGH LOGIN REDIRECT (two login redirects instead of one)

161 views
Skip to first unread message

Kuntal Paul

unread,
Jul 11, 2020, 12:59:24 PM7/11/20
to Django users
The LOGIN_REDIRECT_URL  only allowing to redirect to a particular profile page. But in scenarios like where there are students and teachers, both of them need their specific profile page after login. 

Using LOGIN_REDIRECT_URL, both the teachers and the students are getting redirected to the same profile ( in my case, both of them either entirely to teachers profile or entirely to students profile). 

How can I set two login redirects instead of one? I searched in the documentation, online videos, and everything but couldn't find such. Please help me with resources/codes/guide/etc from where I can learn from and implement. I'm pretty new to this and have tried whatever I know till now.

Thank You.

oba stephen

unread,
Jul 11, 2020, 1:12:46 PM7/11/20
to django...@googlegroups.com
You can consider redirecting to a URL that handles the request.

That is a View function that checks if the user is a student or teacher, then renders the respective profiles.

Regards

--
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/e185b4ba-2219-4a1b-bba2-8ef4e4466682o%40googlegroups.com.

Kuntal Paul

unread,
Jul 11, 2020, 1:22:52 PM7/11/20
to django...@googlegroups.com
Thank you for your response. I did this way and it was giving me a 405 error. I couldn't find my mistake. I was saving both of them as student and as teacher separately from auth.user.
     Also, do I have to provide a separate temple for that view?


Damanjeet Singh

unread,
Jul 11, 2020, 1:58:46 PM7/11/20
to django...@googlegroups.com

Gabriel Araya Garcia

unread,
Jul 11, 2020, 2:11:48 PM7/11/20
to django...@googlegroups.com
Kuntal:
I have resolved that issue, but we can make interchange of information:
I need the Ajax code where I can evaluate in onblur text html if one patient is found or not. The field key in the text box is RUT (each person have one in my country)
for example, my rut is 7841349-2, and it's only, no other person have it. In other words, I need evaluate the information text when the user get out of this field (text box).
It doesn't help me evaluate it in submit buttom.
I need the following things:
-The template with with two fields, rut and name
-The AJAX code
-The DJANGO VIEW, where it do the seek patient
If you send this information I will send you one bit WORD file with images how can controller the users permissions

We can help each other to achieve our respective goals






Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos
99.7721.15.70



oba stephen

unread,
Jul 11, 2020, 2:18:33 PM7/11/20
to django...@googlegroups.com
It should work.

Try the link Damanjeet shared.
If you still get an error, share the error message.

Kuntal Paul

unread,
Jul 12, 2020, 3:58:41 AM7/12/20
to django...@googlegroups.com
Thanks a lot for help. That worked.

Reply all
Reply to author
Forward
0 new messages