2014-01-05 88 views
2

我無法克服在django 1.6應用下創建新的sqlite3數據庫的問題。當我做python manage.py syncdb那麼它允許我創建像一些表:Django sqlite3 - manage.py時發生錯誤syncdb

Creating table django_admin_log             
Creating table auth_permission             
Creating table auth_group_permissions           
Creating table auth_group              
Creating table auth_user_groups             
Creating table auth_user_user_permissions          
Creating table auth_user               
Creating table django_content_type            
Creating table django_session 

...但一些回溯它有一個錯誤完成之後:

Traceback (most recent call last):            
    File "manage.py", line 10, in <module>           
    execute_from_command_line(sys.argv)           
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/__init_ 
_.py", line 399, in execute_from_command_line         
    utility.execute()               
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/__init_ 
_.py", line 392, in execute              
    self.fetch_command(subcommand).run_from_argv(self.argv)      
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/base.py 
", line 242, in run_from_argv             
    self.execute(*args, **options.__dict__)          
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/base.py 
", line 285, in execute               
    output = self.handle(*args, **options)          
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/base.py 
", line 415, in handle               
    return self.handle_noargs(**options)           
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/command 
s/syncdb.py", line 112, in handle_noargs           
    emit_post_sync_signal(created_models, verbosity, interactive, db)   
    File "/usr/local/alwaysdata/python/django/1.6.1/django/core/management/sql.py" 
, line 216, in emit_post_sync_signal            
    interactive=interactive, db=db)            
    File "/usr/local/alwaysdata/python/django/1.6.1/django/dispatch/dispatcher.py" 
, line 185, in send                
    response = receiver(signal=self, sender=sender, **named)      
    File "/usr/local/alwaysdata/python/django/1.6.1/django/contrib/auth/management 
/__init__.py", line 82, in create_permissions         
    ctype = ContentType.objects.db_manager(db).get_for_model(klass)    
    File "/usr/local/alwaysdata/python/django/1.6.1/django/contrib/contenttypes/mo 
dels.py", line 47, in get_for_model            
    defaults = {'name': smart_text(opts.verbose_name_raw)},      
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/models/manager.py", 
line 154, in get_or_create              
    return self.get_queryset().get_or_create(**kwargs)       
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/models/query.py", li 
ne 388, in get_or_create               
    six.reraise(*exc_info)              
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/models/query.py", li 
ne 379, in get_or_create               
    with transaction.atomic(using=self.db):          
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/transaction.py", lin 
e 277, in __enter__ 
    connection._start_transaction_under_autocommit() 
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/sqlite3/bas 
e.py", line 436, in _start_transaction_under_autocommit 
    self.cursor().execute("BEGIN") 
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/util.py", l 
ine 69, in execute 
    return super(CursorDebugWrapper, self).execute(sql, params) 
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/util.py", l 
ine 53, in execute 
    return self.cursor.execute(sql, params) 
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/utils.py", line 99, 
in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/util.py", l 
ine 51, in execute 
    return self.cursor.execute(sql) 
    File "/usr/local/alwaysdata/python/django/1.6.1/django/db/backends/sqlite3/bas 
e.py", line 448, in execute 
    return Database.Cursor.execute(self, query) 
django.db.utils.OperationalError: cannot start a transaction within a transaction 

我的設置我的包括:

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.sqlite3', 
     'NAME': 'database.db', 
    }             
} 

我不知道如何解決這個問題。請有人幫助我嗎?

+0

請發佈追蹤 – sk1p

+0

就像你說的。 – krzyhub

回答

3

我假設您使用的是Alwaysdata的託管服務,因爲我谷歌搜索這個問題,這裏是在Alwaysdata的論壇上的相同問題:Django sqlite3 - an error when manage.py syncdb

我解決這個問題的方法是在我的Alwaysdata管理頁面切換到較低版本的Django(例如1.5.5)。然後可以成功創建數據庫文件。

我還沒有明白爲什麼會發生這種情況。

相關問題