1

I have created a working Django application. I am using django-allauth for implementing social-account authentication.

Now, suppose I am logged-in inside my application using an e-mail id whose user does not have a staff access and, if I open admin login page directly, the admin login page is displayed as follows:

admin login page

My question is: how can I stop Django from displaying the message "Successfully signed in as ... "? Where is the source of this message present?

Ralf
  • 16,086
  • 4
  • 44
  • 68
A Shukla
  • 13
  • 2

3 Answers3

1

The Successfully signed in message is a message from django-allauth. It uses the messages framework.

I suggest that you add the template code to display messages to your base template. That way, the message will be displayed immediately after you have logged in, rather than when you go directly to the admin login (which does include the template code to display messages).

Alasdair
  • 298,606
  • 55
  • 578
  • 516
0

The text you are referring to (You are authenticated as ...) can be found in this template:

python3.6/site-packages/django/contrib/admin/templates/admin/login.html

You can override this template to remove the messsage. For example, look into this question for how to override djangos default templates.

Ralf
  • 16,086
  • 4
  • 44
  • 68
0

To override this you need to inherit the template by {% extends "admin/login.html" %}

Then you need to override the block with the name.

{% blocktrans trimmed %} You are authenticated as {{ username }}, but are not authorized to access this page. Would you like to login to a different account? {% endblocktrans %}

Now you can customize this particular line and then point your function to load your custom html file instead of the standard admin ones or you can directly edit the login.html in your django package(Not a good idea). To know where it is fetching from you can do the following...

$python
>>>import sys
>>>sys.path = sys.path[1:]
>>>import django
>>>print(django.__path__)

And then go into contrib\admin\templates\admin and edit the login.html manually.

Vineeth Sai
  • 3,389
  • 7
  • 23
  • 34