Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?


More than 5 years have passed since last update.

python manage.py shell を実行すればsettings.pyが指定された状態になるため,こちらを使用する方が良いです.


In [1]: import django.shortcuts
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.

インポートするためには環境変数DJANGO_SETTINGS_MODULEに,設定を記載したモジュールを教えてやる必要がある. デフォルトではDjangoプロジェクト直下のsettings.pyを指定してやれば良い.

In [2]: import os
In [3]: os.environ['DJANGO_SETTINGS_MODULE'] = 'mokumoku.settings'
In [4]: import django.shortcuts
In [5]: help(django.shortcuts)


I'm mainly interested in Python, Objective-C, Java, Android.
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away