I'm working on custom authorization backend for Django 2.2. I don't want django to update last_login
for user so I wanted to disconnect signal user_logged_in
from triggering update_last_login
.
I also have to do monkey patch in SimpleJWT library changing User to point OtherUserModel
Where is the best place to put this code? For now, I have added in CoreConfig.ready
method and it works but is it a good place for this logic?
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = 'core'
def ready(self):
from django.contrib.auth import user_logged_in
from django.contrib.auth.models import update_last_login
user_logged_in.disconnect(update_last_login, dispatch_uid='update_last_login')
import rest_framework_simplejwt.state
rest_framework_simplejwt.state.User = OtherUserModel