我无法启动manage.py runserver
。我正在使用卡桑德拉数据库,我已经导入了所有所需的模块。我正在试着运行一个非常基本的应用程序。
我在windows 10上运行python 2.7。下面是我得到的错误:
C:UsersAdityaDesktoptry_cassandratry_cass>manage.py runserver
C:Python27libsite-packagesdjangodbutils.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:Python27libsite-packagesdjangodbutils.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:Python27libsite-packagesdjangoutilsautoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "C:Python27libsite-packagesdjangocoremanagementcommandsrunserver.py", line 116, in inner_run
self.check_migrations()
File "C:Python27libsite-packagesdjangocoremanagementcommandsrunserver.py", line 168, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "C:Python27libsite-packagesdjangodbmigrationsexecutor.py", line 19, in __init__
self.loader = MigrationLoader(self.connection)
File "C:Python27libsite-packagesdjangodbmigrationsloader.py", line 47, in __init__
self.build_graph()
File "C:Python27libsite-packagesdjangodbmigrationsloader.py", line 182, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:Python27libsite-packagesdjangodbmigrationsrecorder.py", line 60, in applied_migrations
return set(tuple(x) for x in self.migration_qs.values_list("app", "name"))
File "C:Python27libsite-packagesdjangodbmodelsquery.py", line 162, in __iter__
self._fetch_all()
File "C:Python27libsite-packagesdjangodbmodelsquery.py", line 965, in _fetch_all
self._result_cache = list(self.iterator())
File "C:Python27libsite-packagesdjangodbmodelsquery.py", line 1220, in iterator
for row in compiler.results_iter():
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 794, in results_iter
results = self.execute_sql(MULTI)
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 829, in execute_sql
sql, params = self.as_sql()
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 378, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup()
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 48, in pre_sql_setup
self.setup_query()
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 39, in setup_query
self.select, self.klass_info, self.annotation_col_map = self.get_select()
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 219, in get_select
ret.append((col, self.compile(col, select_format=True), alias))
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 357, in compile
sql, params = node.as_sql(self, self.connection)
File "C:Python27libsite-packagesdjangodbmodelsexpressions.py", line 619, in as_sql
return "%s.%s" % (qn(self.alias), qn(self.target.column)), []
File "C:Python27libsite-packagesdjangodbmodelssqlcompiler.py", line 348, in quote_name_unless_alias
r = self.connection.ops.quote_name(name)
File "C:Python27libsite-packagesdjangodbbackendsbaseoperations.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
以下是我在settings.py
中的数据库设置:
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
}
}
}
}
尝试删除INSTALLED_APPS is settings.py中列出的值
删除 django.contrib。staticfiles为我做到了这一点,或者将django_cassandra_engine放在INSTALLED_APPS列表的顶部
你的错误与django-cassandra-engine后端没有实现quote_name
方法有关。这是一种方法,当表或字段名包含不规则字符时,它只在表或字段名周围加上引号。最简单的修复方法可能是检查所有的表和字段名,并确保只有ASCII字符而没有其他字符(例如,您是否使用unicode字符?)。
如果这不起作用,你的其他选择是:
- 在django-cassandra-engine中提出一个问题。这个项目看起来很活跃,所以可能不会花很长时间来修复。
- 自己修复问题:clone &手动安装django-cassandra-engine,然后在
base/operations.py
中添加quote_name
的实现。身体需要像return '"%s"' % name
一样简单。如果你这样做,它的工作,你可以提交一个pull请求获得永久修复。