dj-rest-auth icon indicating copy to clipboard operation
dj-rest-auth copied to clipboard

ACCOUNT_EMAIL_REQUIRED and EMAIL_REQUIRED are deprecated as of allauth 65.5

Open browniebroke opened this issue 9 months ago • 5 comments

Similar as https://github.com/iMerica/dj-rest-auth/issues/679 django-allauth refactored the settings to control which fields are required. Extract from the release notes:

Simplified signup form configuration. The following settings all controlled signup form: ACCOUNT_EMAIL_REQUIRED, ACCOUNT_USERNAME_REQUIRED, ACCOUNT_SIGNUP_EMAIL_ENTER_TWICE, ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE. This setup had its issues. For example, when email was not required it was still available as an optional field, whereas the username field disappeared when not required. Also, for phone/SMS support, additional settings would have been required. The settings are now all deprecated, and replaced by one new setting: ACCOUNT_SIGNUP_FIELDS, which can be configured to e.g. ['username*', 'email', 'password1*', 'password2*'] to indicate which fields are present and required ('*'). This change is performed in a backwards compatible manner.

Here are the warnings I caught as emitted from dj-rest-auth:

  /opt/.venv/lib/python3.12/site-packages/dj_rest_auth/registration/serializers.py:228: UserWarning: app_settings.USERNAME_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['username']['required']
    required=allauth_account_settings.USERNAME_REQUIRED,
  /opt/.venv/lib/python3.12/site-packages/dj_rest_auth/registration/serializers.py:230: UserWarning: app_settings.EMAIL_REQUIRED is deprecated, use: app_settings.SIGNUP_FIELDS['email']['required']
    email = serializers.EmailField(required=allauth_account_settings.EMAIL_REQUIRED)

browniebroke avatar Mar 22 '25 11:03 browniebroke

I added a PR that might help with this: https://github.com/iMerica/dj-rest-auth/pull/686

chellman avatar Apr 01 '25 20:04 chellman

+1

AtitBimali avatar Apr 11 '25 17:04 AtitBimali

When can this be merged? Receiving warnings because of this

pratyaksh123 avatar Aug 05 '25 04:08 pratyaksh123

@iMerica there are hopes for a new release?

Mte90 avatar Sep 03 '25 09:09 Mte90

Temporary monkey patch example

NOTE: Test it before using in your codebase.

Add this to settings.py after allauth definitions:

# ....
from allauth.account import app_settings as allauth_account_settings
#...

# Bridge deprecated allauth flags for third-party packages (e.g. dj-rest-auth)
_signup_required_map = {
    field.rstrip("*"): field.endswith("*") for field in ACCOUNT_SIGNUP_FIELDS
}
allauth_account_settings.USERNAME_REQUIRED = _signup_required_map.get(
    "username", True
)
allauth_account_settings.EMAIL_REQUIRED = _signup_required_map.get(
    "email", True
)

Versions I used:

django-allauth==65.7.0
dj-rest-auth==7.0.1

elmsec avatar Oct 10 '25 12:10 elmsec