gpt4 book ai didi

python - 为什么 django 提示我还没有设置我的引擎?

转载 作者:行者123 更新时间:2023-12-01 06:16:10 25 4
gpt4 key购买 nike

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'djangobb', # Or path to database file if using sqlite3.
'USER': 'root', # Not used with sqlite3.
'PASSWORD': 'root', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}

有什么想法吗?我无法使用manage.py运行syncdb命令:

    Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.2.1
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.sitemaps',
'django.contrib.admin',
'django.contrib.admindocs',
'registration',
'django_authopenid',
'djangobb_forum',
'djapian',
'messages']
Installed Middleware:
('django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',
'django_authopenid.middleware.OpenIDMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'djangobb_forum.middleware.LastLoginMiddleware',
'djangobb_forum.middleware.UsersOnline')


Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
80. response = middleware_method(request)
File "C:\Python25\Lib\site-packages\django\middleware\locale.py" in process_request
16. language = translation.get_language_from_request(request)
File "C:\Python25\Lib\site-packages\django\utils\translation\__init__.py" in get_language_from_request
90. return real_get_language_from_request(request)
File "C:\PYTHON25\lib\site-packages\django\utils\functional.py" in _curried
55. return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
File "C:\Python25\Lib\site-packages\django\utils\translation\__init__.py" in delayed_loader
36. return getattr(trans, real_name)(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\utils\translation\trans_real.py" in get_language_from_request
339. lang_code = request.session.get('django_language', None)
File "C:\Python25\Lib\site-packages\django\contrib\sessions\backends\base.py" in get
63. return self._session.get(key, default)
File "C:\Python25\Lib\site-packages\django\contrib\sessions\backends\base.py" in _get_session
172. self._session_cache = self.load()
File "C:\Python25\Lib\site-packages\django\contrib\sessions\backends\db.py" in load
20. expire_date__gt=datetime.datetime.now()
File "C:\Python25\lib\site-packages\django\db\models\manager.py" in get
132. return self.get_query_set().get(*args, **kwargs)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in get
336. num = len(clone)
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in __len__
81. self._result_cache = list(self.iterator())
File "C:\Python25\Lib\site-packages\django\db\models\query.py" in iterator
269. for row in compiler.results_iter():
File "C:\Python25\Lib\site-packages\django\db\models\sql\compiler.py" in results_iter
672. for rows in self.execute_sql(MULTI):
File "C:\Python25\Lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
717. sql, params = self.as_sql()
File "C:\Python25\Lib\site-packages\django\db\models\sql\compiler.py" in as_sql
56. out_cols = self.get_columns(with_col_aliases)
File "C:\Python25\Lib\site-packages\django\db\models\sql\compiler.py" in get_columns
185. col_aliases)
File "C:\Python25\Lib\site-packages\django\db\models\sql\compiler.py" in get_default_columns
273. r = '%s.%s' % (qn(alias), qn2(field.column))
File "C:\Python25\Lib\site-packages\django\db\models\sql\compiler.py" in quote_name_unless_alias
43. r = self.connection.ops.quote_name(name)
File "C:\Python25\lib\site-packages\django\db\backends\dummy\base.py" in complain
15. raise ImproperlyConfigured("You haven't set the database ENGINE setting yet.")

Exception Type: ImproperlyConfigured at /admin/
Exception Value: You haven't set the database ENGINE setting yet.

最佳答案

我设置了旧方式和新方式,这样它就不是特定于 django 版本的:

DATABASE_ENGINE   = 'django.db.backends.sqlite3'
DATABASE_NAME = '/path/to/db/foo.sqlite3'
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''

DATABASES = {
'default': {
'ENGINE': DATABASE_ENGINE,
'NAME': DATABASE_NAME,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'HOST': DATABASE_HOST,
'PORT': DATABASE_PORT,
}
}

但是,是的,我会仔细检查您的安装是否是您认为的版本。

更新:

您可能正在尝试从管理模块的设置中导入某些内容,并在设置中导入管理模块。有时循环导入会导致上述情况。

特别是,在设置中使用反向(“url-name”)可能会导致这种情况,因为它最终会迫使它在某个深暗级别查看“站点”表...

更新2:

抱歉,解释一下上面的内容:

  • 循环导入是指模块 A 从模块 B 导入,并且在某种程度上,模块 B 也需要模块 A 中的内容。在第二个深度级别的某个时刻,它通常会以某种难以理解的方式失败。<
  • Reverse() 是将 url 名称(urls.py 中的 name="foo")转换回 url 本身的函数。这使得设置或管理模块中并不总是可以进行调用。

更新3:

查看您指向的票证 djangobb.org/ticket/81,为了分解一些术语,csrf token 是一个模板标记,用于添加跨站点请求伪造保护:

http://docs.djangoproject.com/en/dev/ref/contrib/csrf/

它通常看起来像这样,从我的项目中 grep:

# grep -ri csrf .
./registration/login.html: <form method="post" action="{% url django.contrib.auth.views.login %}">{% csrf_token %}

关于 djapian 主干的一点,虽然我自己不知道 djapian 是什么,通常意味着直接安装(通常是 svn)主干 - 或“最新的, checkin 的版本,这是较新的”比任何发布的、可能经过测试的官方版本”。通常,这涉及执行诸如 svn checkout http://wherever.com/someproject/trunk/./someproject 之类的操作,然后转到该目录进行安装。

关于python - 为什么 django 提示我还没有设置我的引擎?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3249142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com