Python 可以在Django中运行manage.py runserver
我无法启动Python 可以在Django中运行manage.py runserver,python,django,python-2.7,cassandra,manage.py,Python,Django,Python 2.7,Cassandra,Manage.py,我无法启动manage.py runserver。我使用的是Cassandra数据库,我已经导入了所有必需的模块。我正在尝试运行非常基本的应用程序 我正在Windows10上运行python 2.7。以下是我得到的错误: C:\Users\Aditya\Desktop\try_cassandra\try_cass>manage.py runserver C:\Python27\lib\site-packages\django\db\utils.py:238: RemovedInDjango
manage.py runserver
。我使用的是Cassandra数据库,我已经导入了所有必需的模块。我正在尝试运行非常基本的应用程序
我正在Windows10上运行python 2.7。以下是我得到的错误:
C:\Users\Aditya\Desktop\try_cassandra\try_cass>manage.py runserver
C:\Python27\lib\site-packages\django\db\utils.py:238: RemovedInDjango19Warning: In Django 1.9 the TEST_NAME connection setting will be moved to a NAME entry in the TEST setting
self.prepare_test_settings(alias)
C:\Python27\lib\site-packages\django\db\utils.py:238: RemovedInDjango19Warning: In Django 1.9 the TEST_NAME connection setting will be moved to a NAME entry in the TEST setting
self.prepare_test_settings(alias)
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function wrapper at 0x0454D030>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check_migrations()
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 168, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:\Python27\lib\site-packages\django\db\migrations\executor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 47, in __init__
self.build_graph()
File "C:\Python27\lib\site-packages\django\db\migrations\loader.py", line 182, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Python27\lib\site-packages\django\db\migrations\recorder.py", line 60, in applied_migrations
return set(tuple(x) for x in self.migration_qs.values_list("app", "name"))
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 162, in __iter__
self._fetch_all()
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 1220, in iterator
for row in compiler.results_iter():
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 794, in results_iter
results = self.execute_sql(MULTI)
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 829, in execute_sql
sql, params = self.as_sql()
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 378, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup()
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 48, in pre_sql_setup
self.setup_query()
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 39, in setup_query
self.select, self.klass_info, self.annotation_col_map = self.get_select()
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 219, in get_select
ret.append((col, self.compile(col, select_format=True), alias))
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 357, in compile
sql, params = node.as_sql(self, self.connection)
File "C:\Python27\lib\site-packages\django\db\models\expressions.py", line 619, in as_sql
return "%s.%s" % (qn(self.alias), qn(self.target.column)), []
File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 348, in quote_name_unless_alias
r = self.connection.ops.quote_name(name)
File "C:\Python27\lib\site-packages\django\db\backends\base\operations.py", line 317, in quote_name
raise NotImplementedError('subclasses of BaseDatabaseOperations may require a quote_name() method')
NotImplementedError: subclasses of BaseDatabaseOperations may require a quote_name() method
您的错误与django cassandra引擎后端使用
quote\u name
方法有关。这是一种方法,当表或字段名包含不规则字符时,只在其周围加引号。最简单的修复方法可能是检查所有表名和字段名,确保只有ASCII字符而没有其他字符(例如,您是否使用unicode字符?)
如果这不起作用,您的其他选择是:
- 提出一个问题。该项目看起来处于活动状态,因此可能不需要很长时间就能得到修复
- 自己解决问题:克隆并手动安装django cassandra引擎,然后在
中添加base/operations.py
的实现。正文只需像quote\u name
那样。如果您这样做了,并且它工作了,那么您可以提交一个pull请求以获得永久修复return''%s''%name
删除django.contrib.staticfiles对我来说是个好办法,或者将django\u cassandra\u引擎放在已安装的应用程序列表的顶部发布你的
settings.py
的数据库部分。也给我们一些更多的细节。你是如何将卡桑德拉与django一起使用的?通过django Nonl、django cassandra engine?另外,您得到的错误是回溯中的最后一行:NotImplementedError:BaseDatabaseOperations的子类可能需要quote_name()方法
。这很可能意味着您的数据库设置或正在使用的后端模块有问题。@gbs我已经编辑了这个问题,您现在可以检查一下吗。thanxif我直接从数据库返回它返回的行,就像Row(phno=123,age=22,uname=u'mathur')Row(phno=234,age=22,uname=u'mathur')一样,所以我认为有unicode字符,如何删除它们,我不是很擅长,我只是开始了这个。@Aditya,如果您刚开始使用django,我建议您先使用一个受支持的数据库,直到您熟悉它为止。django cassandra引擎是一个实验性后端,有很多限制,可能需要您进行一些修改才能在实践中使用。现在,正如我在回答中提到的,你可以就这个具体问题联系作者。thanx,我错过了。它工作起来很有魅力。
DATABASES = {
'default': {
'ENGINE': 'django_cassandra_engine',
'NAME': 'db',
'TEST_NAME': 'test_db',
'HOST': '127.0.0.1',
'OPTIONS': {
'replication': {
'strategy_class': 'SimpleStrategy',
'replication_factor': 1
}
}
}
}