Questions tagged [django-authentication]

django-authentication refers to the built-in auth module for authentication & authorization that can be extended.

django-authentication refers to the built-in auth module for authentication & authorization that can be extended. It handles user accounts, groups, permissions and cookie-based user sessions.

See documentation.

1888 questions
8
votes
2 answers

Database error: no such table: auth_user. Extending AbstractUser and using model to register on admin

I'm trying to use AbstractUser to add a field to Django's standard User model. This is my code: class GUser(AbstractUser): uuid = UUIDField(auto=True) This has been successful because from the shell I can say, >>> a = GUser.objects.all() >>>…
8
votes
2 answers

Django/Auth: logout clears the session data?

I would like to know if auth.logout clears session data or i have to do it by my self. from django.contrib.auth.decorators import login_required from django.contrib import auth @login_required def logout(request): auth.logout(request) return…
8
votes
2 answers

Django- how to use built-in login view with email instead of username?

I am using built-in login in my app. There is some custom backends or packages to handle this. but many of them are not what i am looking. i made email unique via django-registration while registering. now all i want is to ask email in login page…
alioguzhan
  • 7,657
  • 10
  • 46
  • 67
8
votes
2 answers

Django - Testing - Problems with @login_required decorator

Problem UPDATE: This issue, it turns out, has little to do with the @login_required decorator! I am getting finicky behavior when I try to test views that are decorated with @login_required. I have one test that is actually able to go to a view…
floer32
  • 2,190
  • 4
  • 29
  • 50
7
votes
2 answers

Could not import 'rest_framework_jwt.authentication.JSONWebTokenAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'

Full Error: Could not import 'rest_framework_jwt.authentication.JSONWebTokenAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: cannot import name 'smart_text' from 'django.utils.encoding' REST_FRAMEWORK = { …
7
votes
1 answer

Is one authentication method more secure for a Django DRF backend?

I want to use the most secure method to store my logged in users session in a cookie. the backend is built on Django & DRF, so I'm choosing between the simplejwt plugin for token auth or djangos default SessionAuth. the frontend isnt SPA, but will…
7
votes
1 answer

How to implement ldap authentication(without admin credentials) in django

My setup: Django-3.0, Python-3.8, django_auth_ldap I have LDAP Server (Active Directory Server) in my organization. I am building a Django Application which serves some operations for all the users. I know Django has built-in User Authentication…
shivappa
  • 153
  • 1
  • 11
7
votes
5 answers

Django admin failing to login after upgrade to 2.1

After upgrading an old Django 1.8 to 2.1, when I try to login on my admin site, I get a 404 with message: Using the URLconf defined in .urls, Django tried these URL patterns, in this order: [...] The current path, login/, didn't match any of…
7
votes
3 answers

Relogin after N minutes with django and JWT

Scenario: I want a user to re-login when passing to a security sensible area after N minutes, e.g. when user is about to pay an order, however he logged in 1 hour ago, I would like to be sure it's him. This by using rest_framework_jwt. Long…
7
votes
1 answer

The current path, account/login/, didn't match any of these?

I'm trying to access my project (local), and I am getting this traceback: traceback Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/account/login/ Using the URLconf defined in tutorial.urls, Django tried these URL…
JosephS
  • 181
  • 1
  • 3
  • 13
7
votes
2 answers

Django - User admin - adding groups to list_display

As we know, ManytoMany relations can't be listed in list_display. Is there any work around to make it like group1, group2 etc?
Siva Arunachalam
  • 7,582
  • 15
  • 79
  • 132
7
votes
1 answer

Is creating an accounts app in Django a good practice?

I am wondering if creating an accounts app in Django is a good practice. Say you have a Django project named mysite and you create inside two apps: core, which holds some business logic, and accounts. mysite/accounts/urls.py urlpatterns = [ …
Fred
  • 71
  • 1
  • 7
7
votes
3 answers

Detect a changed password in Django

When a user changes their password, I want to send a signal so that I can do some stuff on some models. How can I create this signal? I've looked at the post_save signal for User: post_save.connect(user_updated, sender=User) However, there doesn't…
43Tesseracts
  • 4,617
  • 8
  • 48
  • 94
7
votes
1 answer

How to authenticate a User

I have created two different types of users - truck & company. Here is my registration page for a user After registering, the data about whether the user is a truck or company will go to the database. In my login page, only Email and Password are…
vanam
  • 135
  • 1
  • 4
  • 14
7
votes
1 answer

Django + JSON web tokens + disabling session-based authorization

I am currently working on a Django project that wants to replace and disable Django's traditional cookie-based sessions and replace it with JSON web tokens as a means of user authentication for a user on my website.(User Authentication for the…