This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
dj-rest-auth is a Django REST Framework package providing authentication API endpoints (login, logout, registration, password reset/change, JWT auth). It integrates with django-allauth for social auth and registration.
# All tests
python runtests.py
# Single test
DJANGO_SETTINGS_MODULE=dj_rest_auth.tests.settings python -m django test dj_rest_auth.tests.test_api.APIBasicTests.test_login
# With coverage
coverage run ./runtests.py && coverage reportflake8 dj_rest_auth/tox # all envs
tox -e flake8 # lint only
tox -e coverage # coverage onlypip install -r dj_rest_auth/tests/requirements.txtapp_settings.py— Central configuration viaREST_AUTHDjango setting dict. All serializers and the token model are specified as dotted import strings, making everything overridable without subclassing. Access settings via theapi_settingssingleton.views.py—LoginView,LogoutView,UserDetailsView,PasswordResetView,PasswordResetConfirmView,PasswordChangeView. All views usethrottle_scope = 'dj_rest_auth'.serializers.py— Core serializers for all auth operations.jwt_auth.py—JWTCookieAuthentication(subclasses simplejwt'sJWTAuthentication), cookie helpers, refresh view factory. Only active whenUSE_JWT=True.urls.py— Usesre_pathwith trailing/?to make slashes optional. JWT endpoints conditionally registered.models.py— No custom models; resolves and re-exports the configured Token model viaget_token_model().
Requires django-allauth. Provides RegisterView, VerifyEmailView, social login/connect views, and corresponding serializers.
- Conditional allauth integration: Checks
'allauth' in settings.INSTALLED_APPSat runtime to branch between allauth and plain Django auth. - Settings-as-import-strings: Serializers, token model, and token creator are all configurable via dotted path strings in
REST_AUTH. - Custom validation hooks:
custom_validation()methods on password serializers for subclass extension. - i18n: All user-facing strings use
gettext_lazy.
settings.py— Test Django settings (SQLite in-memory, allauth configured).mixins.py—TestsMixinwith HTTP helpers and status assertions; customAPIClient.utils.py—override_api_settingscontext manager for temporarily changingREST_AUTHvalues in tests.- Test files:
test_api.py,test_serializers.py,test_social.py,test_utils.py.
- flake8 with max line length 120 (configured in
setup.cfg) F403(star imports) ignored globally