Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

django authenticate error with DJANGO_SETTINGS_MODULE

$
0
0

im new to django . I was doing some things to figure out how the code works. I did some part of the tutorial. I have an app folder named polls and the standard mysite folder where there is the settings.py file .

I created another python file in mysite folder , auth.py and I wrote this code :

from django.contrib.auth import authenticateuser_auth = authenticate(username = "test-username", password = "test-password")print(user_auth)

What I want to do is just see what the authenticate function returns. I want to know certain things like , where are the credentials searched for the authentication. I don't know any of that and that's the reason I want to print some things in the code.

First question is, can I do that ? I always have learned coding with actually doing the things from the very basics, looking for what is happening with the code .

The second question is that im trying to run the code but it gives me an error :

django.core.exceptions.ImproperlyConfigured: Requested setting AUTHENTICATION_BACKENDS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I searched in google and I found the next terminal-solution:

export DJANGO_SETTINGS_MODULE=mysite.settings

But still doesn't work.

Maybe I'm making all wrong? Maybe I just can't use authenticate just like that, and I need a lot more of things to do before I can run the authenticate function? I don't know because I'm very new, I started just yesterday with django .

I have described it before


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>