Finding the profile name for a join in my Facebook auth backend
You can use django.contrib.auth.get_user_model() instead of importing User directly. Note that I also explicitly included the ObjectDoesNotExist exception.

https://docs.djangoproject.com/en/2.2/topics/auth/customizing/

from django.conf import settings
from django.contrib.auth import get_user_model
from django.core.exceptions import ObjectDoesNotExist
from better_facebook.models import FacebookUser


class FacebookBackend(object):
    """
    Authenticate against a facebook_user object.
    """
    def authenticate(self, facebook_user):
        assert(isinstance(facebook_user, FacebookUser))
        try:
            UserModel = get_user_model()
            return UserModel.objects.get(userprofile__facebook=facebook_user)
        except ObjectDoesNotExist:
            return None

    def get_user(self, user_id):
        try:
            UserModel = get_user_model()
            return UserModel.objects.get(pk=user_id)
        except ObjectDoesNotExist:
            return None
```