Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9219603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:09:11+00:00 2026-06-18T03:09:11+00:00

I am newbee in Django.I finished the Django Tutorial once from the official djangoproject

  • 0

I am newbee in Django.I finished the Django Tutorial once from the official djangoproject site.Not saying I know everything now, but everything worked perfectly for me till I was referring that website.
I started referring to the Practical Django projects book and somewhere in my models I tried to import :

from django.contrib.auth.models import User

gives me an import error :

ImportError Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined
`

What is really going on here ? I have been successfully importing all the packages till now then why this sudden error ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:09:12+00:00Added an answer on June 18, 2026 at 3:09 am

    How are you running the code that gives you the error? If you are importing the models.py in the shell, use the Django shell command

    ./manage.py shell
    

    If you are trying the import in another script, you have to set the environment variable DJANGO_SETTINGS_MODULE manually.

    import os
    
    if 'DJANGO_SETTINGS_MODULE' not in os.environ:
        os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
    

    This requires myproject to be in your python path.

    See this similar Stack Overflow question for futher discussion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So...I a newbie working on a django app but when I try run heroku
I am newbie in Django and wanted to know a very basic thing: I
I'm a newbie for django and mongoengine.. so I'm not sure my code is
I'm making a survey site with django. I am pretty newbie with django so
I am a python newbie. i was trying out a django tutorial and got
I am a newbie in django (and stackoverflow also) but i try to set
a newbie django question I want to use 3rd party app, but I need
I'm a newbie at Django and I want to do something that I'm not
I am newbie to django. I am running this example from https://github.com/openid/python-openid/tree/master/examples/djopenid Any pointers
I am a python/django newbie following along this tutorial on dotcloud . I git

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.