Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No compatibility with django.contrib.auth.apps.AuthConfig #497

Open
afedosenko opened this issue Oct 6, 2021 · 4 comments
Open

No compatibility with django.contrib.auth.apps.AuthConfig #497

afedosenko opened this issue Oct 6, 2021 · 4 comments

Comments

@afedosenko
Copy link

Problem

class AuthConfig(AppConfig):
    name = 'django.contrib.auth'
    verbose_name = _("Authentication and Authorization")

    def ready(self):
        post_migrate.connect(
            create_permissions,
            dispatch_uid="django.contrib.auth.management.create_permissions"
        )
        last_login_field = getattr(get_user_model(), 'last_login', None)
        # Register the handler only if UserModel.last_login is a field.
        if isinstance(last_login_field, DeferredAttribute):
            from .models import update_last_login
            user_logged_in.connect(update_last_login, dispatch_uid='update_last_login')
        checks.register(check_user_model, checks.Tags.models)
        checks.register(check_models_permissions, checks.Tags.models)

if isinstance(last_login_field, DeferredAttribute): is negative
because type(last_login_field) = <class 'model_utils.tracker.DescriptorWrapper'>

Environment

  • Django Model Utils version: 4.1.1
  • Django version: 2.2.24
  • Python version: 3.7.12
@MRigal
Copy link
Member

MRigal commented Oct 7, 2021

Hi @afedosenko
Could you post your custom user model? There might be an issue over there

@afedosenko
Copy link
Author

Hello @MRigal

from django.contrib.auth.models import AbstractUser
from model_utils import FieldTracker


class CustomUser(AbstractUser):
    tracker = FieldTracker()

@tumb1er
Copy link
Contributor

tumb1er commented Oct 7, 2021

Using FieldTracker on custom user model has a long history of issues here on github, and it depends on Django's bugfix also.
I.e.:

#423
#331
#382

https://code.djangoproject.com/ticket/30427#ticket

Looks like it's fixed in Django-4.0

@daniel-butler
Copy link

#514 This is a related issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants