AUTH_USER_MODEL refers to model 'base.User' that has not been installed for custom auth backendExtending the User model with custom fields in Djangodjango - inlineformset_factory with more than one ForeignKeyWhat is wrong with my models.py?Radio buttons in django adminMongoEngine — how to custom User model / custom backend for authenticate()filter json data from Django modelDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to expose some specific fields of model_b based on a field of model_a?Customer User Authentication error : AttributeError: Manager isn't available; 'auth.User' has been swapped for 'user_management.CustomUser'How to set dynamic initial values to django modelform field

How is this kind of structure made?

DeclareMathOperator and widearcarrow with kpfonts

Understanding the point of a kölsche Witz

A tool to replace all words with antonyms

Should I ask for permission to write an expository post about someone's else research?

Should you play baroque pieces a semitone lower?

Double redundancy for the Saturn V LVDC computer memory, how were disagreements resolved?

How to mark beverage cans in a cooler for a blind person?

In SQL Server, why does backward scan of clustered index cannot use parallelism?

constant evaluation when using differential equations.

In a 2 layer PCB with a top layer densely populated, from an EMI & EMC point of view should the ground plane be on top, bottom or both and why?

What does Apple mean by "This may decrease battery life"?

Generate Brainfuck for the numbers 1–255

AsyncDictionary - Can you break thread safety?

The cat ate your input again!

What is the difference between 型 and 形?

Different inverter (logic gate) symbols

Is there a way to unplug the Raspberry pi safely without shutting down

Why did Gandalf use a sword against the Balrog?

Why do funding agencies like the NSF not publish accepted grants?

As a 16 year old, how can I keep my money safe from my mother?

What happen to those who died but not from the snap?

Loading military units into ships optimally, using backtracking

What happens if I delete an icloud backup?



AUTH_USER_MODEL refers to model 'base.User' that has not been installed for custom auth backend


Extending the User model with custom fields in Djangodjango - inlineformset_factory with more than one ForeignKeyWhat is wrong with my models.py?Radio buttons in django adminMongoEngine — how to custom User model / custom backend for authenticate()filter json data from Django modelDjango-Rest-Framework - How to serialize queryset from an unrelated model as nested serializerHow to expose some specific fields of model_b based on a field of model_a?Customer User Authentication error : AttributeError: Manager isn't available; 'auth.User' has been swapped for 'user_management.CustomUser'How to set dynamic initial values to django modelform field






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm trying to customize auth backend while customized auth model but keep facing this error because i'm using get_user_model() function.




django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'base.User' that has not been installed




INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base.apps.BaseConfig',
'core.apps.AccountsConfig',
'system.apps.SystemConfig',
]


custom Backend:



class UserBackend(object):
def authenticate(self, request, username=None, password=None, **kwargs):
usermodel = User
try:
usr = usermodel.objects.get(username=username)
password_valid = usr.check_password(password)
if usr and password_valid:
return usr
raise PermissionDenied
except usermodel.DoesNotExist:
return PermissionDenied
return None

def get_user(self, user_id):
usermodel = User
try:
return usermodel.objects.get(pk=user_id)
except usermodel.DoesNotExist:
return None


Edit:



settings:



AUTH_USER_MODEL = 'base.User'
AUTHENTICATION_BACKENDS = (
'base.models.UserBackend',
)


base.User model:



class User(AbstractUser):
fullname = models.CharField(max_length=35, null=True, blank=True)
picture = models.ManyToManyField('ImageFile', verbose_name="ProfilePicture", blank=True)
bio = models.CharField(max_length=255, null=True, blank=True)
link = models.URLField(null=True, blank=True, default="")
is_private = models.BooleanField(default=False)
is_official = models.BooleanField(default=False)


Note: UserBackend is on the end of file and class User(AbstractUser) is above it










share|improve this question


























  • please show your base.User model

    – Bear Brown
    Mar 27 at 8:41











  • and what is your settings auth first (AUTHENTICATION_BACKENDS, AUTH_USER_MODEL)?

    – Bear Brown
    Mar 27 at 8:47












  • AUTH_USER_MODEL is above! @BearBrown

    – Ebrahim Karimi
    Mar 27 at 8:54












  • Please post the complete stacktrace you are getting

    – Daniel Hepper
    Mar 27 at 9:48

















1















I'm trying to customize auth backend while customized auth model but keep facing this error because i'm using get_user_model() function.




django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'base.User' that has not been installed




INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base.apps.BaseConfig',
'core.apps.AccountsConfig',
'system.apps.SystemConfig',
]


custom Backend:



class UserBackend(object):
def authenticate(self, request, username=None, password=None, **kwargs):
usermodel = User
try:
usr = usermodel.objects.get(username=username)
password_valid = usr.check_password(password)
if usr and password_valid:
return usr
raise PermissionDenied
except usermodel.DoesNotExist:
return PermissionDenied
return None

def get_user(self, user_id):
usermodel = User
try:
return usermodel.objects.get(pk=user_id)
except usermodel.DoesNotExist:
return None


Edit:



settings:



AUTH_USER_MODEL = 'base.User'
AUTHENTICATION_BACKENDS = (
'base.models.UserBackend',
)


base.User model:



class User(AbstractUser):
fullname = models.CharField(max_length=35, null=True, blank=True)
picture = models.ManyToManyField('ImageFile', verbose_name="ProfilePicture", blank=True)
bio = models.CharField(max_length=255, null=True, blank=True)
link = models.URLField(null=True, blank=True, default="")
is_private = models.BooleanField(default=False)
is_official = models.BooleanField(default=False)


Note: UserBackend is on the end of file and class User(AbstractUser) is above it










share|improve this question


























  • please show your base.User model

    – Bear Brown
    Mar 27 at 8:41











  • and what is your settings auth first (AUTHENTICATION_BACKENDS, AUTH_USER_MODEL)?

    – Bear Brown
    Mar 27 at 8:47












  • AUTH_USER_MODEL is above! @BearBrown

    – Ebrahim Karimi
    Mar 27 at 8:54












  • Please post the complete stacktrace you are getting

    – Daniel Hepper
    Mar 27 at 9:48













1












1








1








I'm trying to customize auth backend while customized auth model but keep facing this error because i'm using get_user_model() function.




django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'base.User' that has not been installed




INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base.apps.BaseConfig',
'core.apps.AccountsConfig',
'system.apps.SystemConfig',
]


custom Backend:



class UserBackend(object):
def authenticate(self, request, username=None, password=None, **kwargs):
usermodel = User
try:
usr = usermodel.objects.get(username=username)
password_valid = usr.check_password(password)
if usr and password_valid:
return usr
raise PermissionDenied
except usermodel.DoesNotExist:
return PermissionDenied
return None

def get_user(self, user_id):
usermodel = User
try:
return usermodel.objects.get(pk=user_id)
except usermodel.DoesNotExist:
return None


Edit:



settings:



AUTH_USER_MODEL = 'base.User'
AUTHENTICATION_BACKENDS = (
'base.models.UserBackend',
)


base.User model:



class User(AbstractUser):
fullname = models.CharField(max_length=35, null=True, blank=True)
picture = models.ManyToManyField('ImageFile', verbose_name="ProfilePicture", blank=True)
bio = models.CharField(max_length=255, null=True, blank=True)
link = models.URLField(null=True, blank=True, default="")
is_private = models.BooleanField(default=False)
is_official = models.BooleanField(default=False)


Note: UserBackend is on the end of file and class User(AbstractUser) is above it










share|improve this question
















I'm trying to customize auth backend while customized auth model but keep facing this error because i'm using get_user_model() function.




django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'base.User' that has not been installed




INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'base.apps.BaseConfig',
'core.apps.AccountsConfig',
'system.apps.SystemConfig',
]


custom Backend:



class UserBackend(object):
def authenticate(self, request, username=None, password=None, **kwargs):
usermodel = User
try:
usr = usermodel.objects.get(username=username)
password_valid = usr.check_password(password)
if usr and password_valid:
return usr
raise PermissionDenied
except usermodel.DoesNotExist:
return PermissionDenied
return None

def get_user(self, user_id):
usermodel = User
try:
return usermodel.objects.get(pk=user_id)
except usermodel.DoesNotExist:
return None


Edit:



settings:



AUTH_USER_MODEL = 'base.User'
AUTHENTICATION_BACKENDS = (
'base.models.UserBackend',
)


base.User model:



class User(AbstractUser):
fullname = models.CharField(max_length=35, null=True, blank=True)
picture = models.ManyToManyField('ImageFile', verbose_name="ProfilePicture", blank=True)
bio = models.CharField(max_length=255, null=True, blank=True)
link = models.URLField(null=True, blank=True, default="")
is_private = models.BooleanField(default=False)
is_official = models.BooleanField(default=False)


Note: UserBackend is on the end of file and class User(AbstractUser) is above it







django django-authentication






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 9:04







Ebrahim Karimi

















asked Mar 27 at 8:32









Ebrahim KarimiEbrahim Karimi

1652 silver badges14 bronze badges




1652 silver badges14 bronze badges















  • please show your base.User model

    – Bear Brown
    Mar 27 at 8:41











  • and what is your settings auth first (AUTHENTICATION_BACKENDS, AUTH_USER_MODEL)?

    – Bear Brown
    Mar 27 at 8:47












  • AUTH_USER_MODEL is above! @BearBrown

    – Ebrahim Karimi
    Mar 27 at 8:54












  • Please post the complete stacktrace you are getting

    – Daniel Hepper
    Mar 27 at 9:48

















  • please show your base.User model

    – Bear Brown
    Mar 27 at 8:41











  • and what is your settings auth first (AUTHENTICATION_BACKENDS, AUTH_USER_MODEL)?

    – Bear Brown
    Mar 27 at 8:47












  • AUTH_USER_MODEL is above! @BearBrown

    – Ebrahim Karimi
    Mar 27 at 8:54












  • Please post the complete stacktrace you are getting

    – Daniel Hepper
    Mar 27 at 9:48
















please show your base.User model

– Bear Brown
Mar 27 at 8:41





please show your base.User model

– Bear Brown
Mar 27 at 8:41













and what is your settings auth first (AUTHENTICATION_BACKENDS, AUTH_USER_MODEL)?

– Bear Brown
Mar 27 at 8:47






and what is your settings auth first (AUTHENTICATION_BACKENDS, AUTH_USER_MODEL)?

– Bear Brown
Mar 27 at 8:47














AUTH_USER_MODEL is above! @BearBrown

– Ebrahim Karimi
Mar 27 at 8:54






AUTH_USER_MODEL is above! @BearBrown

– Ebrahim Karimi
Mar 27 at 8:54














Please post the complete stacktrace you are getting

– Daniel Hepper
Mar 27 at 9:48





Please post the complete stacktrace you are getting

– Daniel Hepper
Mar 27 at 9:48












1 Answer
1






active

oldest

votes


















0














There was an import in base.models file, from django.contrib.auth.backends import ModelBackend which caused this error even when i removed custom AUTHENTICATION_BACKENDS.after i removed this import, everything works fine although i moved backend class from base.models to backend file in the base app (i think its not necessary, i just did it for more readable codes)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372753%2fauth-user-model-refers-to-model-base-user-that-has-not-been-installed-for-cust%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    There was an import in base.models file, from django.contrib.auth.backends import ModelBackend which caused this error even when i removed custom AUTHENTICATION_BACKENDS.after i removed this import, everything works fine although i moved backend class from base.models to backend file in the base app (i think its not necessary, i just did it for more readable codes)






    share|improve this answer





























      0














      There was an import in base.models file, from django.contrib.auth.backends import ModelBackend which caused this error even when i removed custom AUTHENTICATION_BACKENDS.after i removed this import, everything works fine although i moved backend class from base.models to backend file in the base app (i think its not necessary, i just did it for more readable codes)






      share|improve this answer



























        0












        0








        0







        There was an import in base.models file, from django.contrib.auth.backends import ModelBackend which caused this error even when i removed custom AUTHENTICATION_BACKENDS.after i removed this import, everything works fine although i moved backend class from base.models to backend file in the base app (i think its not necessary, i just did it for more readable codes)






        share|improve this answer













        There was an import in base.models file, from django.contrib.auth.backends import ModelBackend which caused this error even when i removed custom AUTHENTICATION_BACKENDS.after i removed this import, everything works fine although i moved backend class from base.models to backend file in the base app (i think its not necessary, i just did it for more readable codes)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 27 at 9:52









        Ebrahim KarimiEbrahim Karimi

        1652 silver badges14 bronze badges




        1652 silver badges14 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372753%2fauth-user-model-refers-to-model-base-user-that-has-not-been-installed-for-cust%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript