Superuser account to dashboard in django - django

Is it possible that:
I will login to admin/ using a superuser account but I will be redirected to my app.
or I will login to my custom login form using my superuser account because I'm creating a system that only have one user. And only an admin.
Thanks!

Your app will do what you tell it to do. If you need this specific functionality you can read about customizing the admin here. It would need some type of check to see if the user is a superuser such as:
if request.user.is_superuser:
# redirect to send user to the site main domain here
Hope this helps!

Related

How to prevent django admin login and logout sessions from reflecting in actual website?

I'm quite new to django.
I've made a website that makes use of user auth for login, logout and registration.
Whenever I log into the admin panel, it also gets reflected in the actual website. The admin account gets logged into the website on its own.
I know this is the default behaviour of the django auth system, but I want to separate the auth session of admin panel and the actual website.
How can I do so?
The screenshots below show the thing which I'm talking about.
👇 Here I've logged into the Admin panel.
👇 The Admin account got logged into the website on its own by using the admin session..
I just want that both admin panel and website should have separate auth sessions and shouldn't be linked to each other.
The website is hosted online here
Thanks in advance!
You could write middleware for this, to explicitly logout authenticated users in non-admin pages as suggested in this answer:
https://stackoverflow.com/a/57357586/2135738

How to add a user to django site, when using remote auth backend?

I am using Django for a site, and have a remote auth backend setup. Is there a way In which I can create a new user and give them permissions before they login to the site? I know I can add users through the admin page or directly through the database, but since I do not know the new users password, I am not sure if the system will see them as the same user
I have tried using the admin page, but it says I need to enter a password
I would like to be able to add users to the system before they logon, and give them permissions, so that when they logon they are not redirected to my unauthorized page. Is this possible?
As I understand from your question, You can create the user by using the
python manage.py createsuperuser
which will create the superuser and later on you can edit on this user and can give your permissions.

How to add disable password for django users

I have created a tool for my colleagues and i have integrated SSO with this django application as well.
Now the way i'm planning to authenticate users are like the following.
SSO page is sending the logged in user ID in cookie.
If the logged in user have an account in django users, i'll check for a match and i should authenticate the user.
The challenge i'm facing here is while creating users i have to provide password and i don't want to validate user password again.
Is there a way i can disable the password while we add the user in to django admin itself?
I'm using Django 1.11 with python 3.4.
Let me know your thoughts.

Django view Site as another user from admin without knowing/resetting password

Is there a way in Django for the admin to view site as another user.
This can be used to debug user specific bugs.
As we don't know the password, the only solution I found is to reset the password from djangoadmin and login it to that user.
This functionality is not built-in to django, fortunately like many such cases, the community is there to help.
django-hijack does what you require:
django-hijack allows superusers to hijack (=login as) and work on
behalf of another user.

Overriding login view to redirect user to different page according to their permission

I want to redirect logged in user to different form according to their permission.
So say if user is superuser or admin then he will be redirected to default django admin dash board.
And if user is not a superuser then he will be redirected to different custom dashboard page.
So what is a better way of doing it.