AttributeError:“设置"对象没有属性“ROOT_URLCONF"

问题描述

继我的上一个问题 错误:没有名为 psycopg2.extensions 的模块,我已将我的 mac OS 更新为 Mountain Lion 并安装了 Xcode.我还使用sudo port install py27-psycopg2"安装了 psycopg2.我现在正在尝试运行python manage.py runserver",但收到此错误

Following on from my last question Error: No module named psycopg2.extensions, I have updated my mac OS to Mountain Lion and installed Xcode. I have also installed psycopg2 using 'sudo port install py27-psycopg2'. I am now trying to run 'python manage.py runserver' but am receiving this error

AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'

关于如何解决这个问题并让我的本地主机运行的任何帮助?

Any help on how to fix this and get my localhost running?


解决方案

来自 django 文档:

From django docs:

Django 设置文件包含 Django 安装的所有配置.当你使用 Django 时,你必须告诉它你正在使用哪些设置.通过使用环境变量 DJANGO_SETTINGS_MODULE 来执行此操作.

A Django settings file contains all the configuration of your Django installation. When you use Django, you have to tell it which settings you're using. Do this by using an environment variable, DJANGO_SETTINGS_MODULE.

DJANGO_SETTINGS_MODULE 的值应该是 Python 路径语法,例如mysite.settings.请注意,设置模块应位于Python 导入搜索路径.

The value of DJANGO_SETTINGS_MODULE should be in Python path syntax, e.g. mysite.settings. Note that the settings module should be on the Python import search path.

ROOT_URLCONF

默认:未定义

代表根目录的完整 Python 导入路径的字符串网址配置.例如:mydjangoapps.urls".可以覆盖一个通过在传入的属性 urlconf 上设置每个请求的基础HttpRequest 对象.请参阅 Django 如何处理请求 了解详情.

A string representing the full Python import path to your root URLconf. For example: "mydjangoapps.urls". Can be overridden on a per-request basis by setting the attribute urlconf on the incoming HttpRequest object. See How Django processes a request for details.

相关文章