簡體   English   中英

可以在Django中運行manage.py runserver

[英]Uable to run manage.py runserver in Django

我無法啟動manage.py runserver 我正在使用Cassandra數據庫,並且已經導入了所有必需的模塊。 我正在嘗試運行非常基本的應用程序。

我在Windows 10上運行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

這是我在settings.py數據庫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中列出的值是settings.py

刪除django.contrib.staticfiles對我有用 ,也可以將django_cassandra_engine放在INSTALLED_APPS列表的頂部

您的錯誤與django-cassandra-engine后端未實現 quote_name方法有關。 這是一種在表或字段名稱包含不規則字符時將引號引起來的方法。 最簡單的解決方法可能是遍歷所有表和字段名稱,並確保只有ASCII字符,而沒有其他(例如,您是否使用Unicode字符?)。

如果那不起作用,您的其他選擇是:

  • 提出django-cassandra-engine中的問題 該項目看起來很活躍,因此可能不需要很長時間就能得到修復。
  • 自己解決此問題:克隆並手動安裝django-cassandra-engine,然后在base/operations.pyquote_name添加一個實現。 正文只需要像return '"%s"' % name 如果您這樣做並且可行,則可以提交拉取請求以獲取永久性修復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM