2

I am not able to start manage.py runserver. I am using a Cassandra database and I have imported all the required modules. I am trying to run quite basic application.

I am running python 2.7 on windows 10. Here is the error I am getting:

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

And here are my database settings in 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
            }
        }
    }
}
Rodrigue
  • 3,617
  • 2
  • 37
  • 49
aditya mathur
  • 75
  • 1
  • 2
  • 6
  • Post the database section of your `settings.py`. Also give us a few more details. How are you using Cassandra with django? Through django-nonrel, django-cassandra-engine? – gbs Oct 15 '15 at 09:06
  • Also, the error you're getting is the last line in the traceback: `NotImplementedError: subclasses of BaseDatabaseOperations may require a quote_name() method`. It most likely means that you have something wrong in your DB settings or the backend module you're using. – gbs Oct 15 '15 at 09:08
  • @gbs i have edited the question, can you check now. thanx – aditya mathur Oct 15 '15 at 09:43

2 Answers2

5

Try removing values listed in INSTALLED_APPS is settings.py

Removing django.contrib.staticfiles did the trick for me or place django_cassandra_engine at the top of the INSTALLED_APPS list

algometrix
  • 3,704
  • 2
  • 14
  • 22
0

Your error has to do with the fact that django-cassandra-engine backend doesn't implement the quote_name method. This is a method that just puts quotation marks around a table or field name when they contain irregular characters. The easiest fix is probably to go through all your table and field names and make sure there are only ASCII characters and nothing else (are you using unicode characters for instance?).

If that doesn't work your other options are:

  • Raise an issue in django-cassandra-engine. The project looks active so it might not take long to get a fix.
  • Fix the issue yourself: clone & manually install django-cassandra-engine, then add an implementation for quote_name in base/operations.py. The body needs to simply be something like return '"%s"' % name. If you do and it works, you can submit a pull request to get a permanent fix.
gbs
  • 1,305
  • 13
  • 12
  • if i directly return the rows from database it returns like Row(phno=123, age=22, uname=u'mathur')Row(phno=234, age=22, uname=u'mathur') so i think unicode character is there, how to remove them , i am not very good at this ,i just started this. – aditya mathur Oct 15 '15 at 10:27
  • @Aditya, if you just started working with django I would suggest starting with one of the supported databases until you are familiar with it. django-cassandra-engine is an experimental backend with a lot of limitations and will likely require some modifications from you to be used in practice. Now, as I mentioned in the answer, you can contact the author about this specific issue. – gbs Oct 15 '15 at 13:11