Posts

Showing posts from October, 2026

JWT USING DJANGO REST FRAMEWORK - SIMPLEJWT

   JWT with djangorestframework-simplejwt What changes compared with the PyJWT version Before (PyJWT) Now (simplejwt) jwt_utils.py : you wrote create/decode by hand Deleted. simplejwt builds and verifies tokens authentication.py : you parsed the header, handled expiry and errors A short subclass that only says how to find your User One access token Access token and refresh token , with a ready-made expiry system Manual expiry setting SIMPLE_JWT settings dict Roles, permissions, serializers and ViewSets stay almost the same. Why a subclass is needed: simplejwt assumes Django’s user model ( AUTH_USER_MODEL ). Your User is a separate table (UserId, Username, Password, RoleId), and your project already has migrations and an admin superuser, so switching AUTH_USER_MODEL now would break migrations. The subclass keeps your model and still uses simplejwt for everything else. Step 0: Install bash pip install djangorestframework-simplejwt You can remove PyJWT usage. simplejwt i...