尝试在 Windows 上设置 Django 时:AttributeError: 'Settings'对象没有属性“DATABASES”;

发布于 2024-08-30 04:59:40 字数 1614 浏览 6 评论 0原文

我按照这些说明在 Windows 上设置 Django。我已经安装了 Python 2.6、PostgreSQL 8.4、Python 2.6 的 Psycopg 2.0.14 以及来自 SVN 的最新版本的 Django。

我现在正在按照以下说明运行测试项目(从上面链接的页面复制):

C:\Documents and Settings\John>cd C:\
C:\>mkdir django
C:\>cd django
C:\django>django-admin.py startproject testproject
C:\django>cd testproject
C:\django\testproject>python manage.py runserver

当我运行最后一行时,这是输出:

Validating models...
Unhandled exception in thread started by <function inner_run at 0x01ECB930>
Traceback (most recent call last):
  File "J:\Python26\lib\site-packages\django\core\management\commands\runserver.py", line 48, in inn
er_run
    self.validate(display_num_errors=True)
  File "J:\Python26\lib\site-packages\django\core\management\base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "J:\Python26\lib\site-packages\django\core\management\validation.py", line 22, in get_validat
ion_errors
    from django.db import models, connection
  File "J:\Python26\lib\site-packages\django\db\__init__.py", line 14, in <module>
    if not settings.DATABASES:
  File "J:\Python26\lib\site-packages\django\utils\functional.py", line 273, in __getattr__
    return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'DATABASES'

我是否忘记对数据库执行某些操作?

任何帮助将不胜感激。谢谢你!

编辑:

似乎我所有的问题(包括这个)都是因为我使用 SVN 的 Django 开发版本引起的。我删除了开发版本并安装了Django 1.1.1,终于不再有奇怪的错误消息并且服务器正在运行!

I'm following these instructions in order to set up Django on Windows. I have installed Python 2.6, PostgreSQL 8.4, Psycopg 2.0.14 for Python 2.6 and the latest version of Django from SVN.

I'm now following these instructions to run a test project (copied from the page linked to above):

C:\Documents and Settings\John>cd C:\
C:\>mkdir django
C:\>cd django
C:\django>django-admin.py startproject testproject
C:\django>cd testproject
C:\django\testproject>python manage.py runserver

When I run the last line, this is the output:

Validating models...
Unhandled exception in thread started by <function inner_run at 0x01ECB930>
Traceback (most recent call last):
  File "J:\Python26\lib\site-packages\django\core\management\commands\runserver.py", line 48, in inn
er_run
    self.validate(display_num_errors=True)
  File "J:\Python26\lib\site-packages\django\core\management\base.py", line 249, in validate
    num_errors = get_validation_errors(s, app)
  File "J:\Python26\lib\site-packages\django\core\management\validation.py", line 22, in get_validat
ion_errors
    from django.db import models, connection
  File "J:\Python26\lib\site-packages\django\db\__init__.py", line 14, in <module>
    if not settings.DATABASES:
  File "J:\Python26\lib\site-packages\django\utils\functional.py", line 273, in __getattr__
    return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'DATABASES'

Did I forget to do something with the database?

Any help will be appreciated. Thank you!

EDIT:

Seems like all my problems (including this one) were caused because I used the development version of Django from SVN. I removed the development version and installed Django 1.1.1, and finally there are no more strange error messages and the server is running!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-09-06 04:59:40

Django 的 SVN checkout 版本正在 settings.py 中寻找这样的设置:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase'
    }
}

这与 Django 书籍和许多教程中显示的方式略有不同。

查看在线文档

The SVN checkout version of Django is looking for a setting like this in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase'
    }
}

This is slightly different than the way it's shown in the Django book and many tutorials.

Checkout the online doc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文