pythondjangodjango-shell

Can't check profile model in django python shell


I am trying to run the django shell to understand what is happening to the photos when I upload them.

However when I try to filter for particular users

python manage.py shell
from django.contrib.auth.models import User
user = User.objects.filter(username='name').first()

I get the following error message:

AttributeError: Manager isn't available; 'auth.User' has been swapped for 'classroom.User'

I am guessing this has something to do with this in settings.py

AUTH_USER_MODEL = 'classroom.User'

What should I be typing to get to look at the profile model


Solution

  • You're correct, it does have something to do with:

    AUTH_USER_MODEL = 'classroom.User'
    

    Since you specified what I would assume is a Custom User Model. In which case you woud have to use the method get_user_model() as specified in Django's docs to reference your new User model.

    from django.contrib.auth import get_user_model
    User = get_user_model()