2015-05-19 129 views
-3

我努力學習的Django ....Django的manage.py執行syncdb不工作

我下面的教程,並得到了只要將某個應用....所以,我打開settings.py文件,並我做了這些改變爲「name」和「引擎」,根據教程...這裏:

DATABASES = { 
'default': { 
    'ENGINE': 'django.db.backends.sqlite3', 
    'NAME': '~/django/bin/django_test/storage.db' 
} 

因此,在本教程的後面,它說,爲了真正讓這樣一個文件「storage.db 「要做到這一點:

python manage.py syncdb 

這是res ULT:

/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/commands/syncdb.py:24: RemovedInDjango19Warning: The syncdb command will be removed in Django 1.9 
    warnings.warn("The syncdb command will be removed in Django 1.9", RemovedInDjango19Warning) 

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line 
    utility.execute() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line 330, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 390, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 441, in execute 
    output = self.handle(*args, **options) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/commands/syncdb.py", line 25, in handle 
    call_command("migrate", **options) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line 120, in call_command 
    return command.execute(*args, **defaults) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 441, in execute 
    output = self.handle(*args, **options) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/core/management/commands/migrate.py", line 93, in handle 
    executor = MigrationExecutor(connection, self.migration_progress_callback) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/executor.py", line 19, in __init__ 
    self.loader = MigrationLoader(self.connection) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/loader.py", line 47, in __init__ 
    self.build_graph() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/loader.py", line 180, in build_graph 
    self.applied_migrations = recorder.applied_migrations() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/recorder.py", line 59, in applied_migrations 
    self.ensure_schema() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/migrations/recorder.py", line 49, in ensure_schema 
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()): 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 162, in cursor 
    cursor = self.make_debug_cursor(self._cursor()) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 135, in _cursor 
    self.ensure_connection() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 130, in ensure_connection 
    self.connect() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/utils.py", line 97, in __exit__ 
    six.reraise(dj_exc_type, dj_exc_value, traceback) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 130, in ensure_connection 
    self.connect() 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/base/base.py", line 119, in connect 
    self.connection = self.get_new_connection(conn_params) 
    File "/Users/angel/django/lib/python2.7/site-packages/Django-1.8.1-py2.7.egg/django/db/backends/sqlite3/base.py", line 204, in get_new_connection 
    conn = Database.connect(**conn_params) 
django.db.utils.OperationalError: unable to open database file> 
+0

Oo,你輸入了什麼,應該發生什麼,發生了什麼?嘗試至少格式化你的stracktrace,並詳細闡述你的問題... – Jingo

+0

哎呀你是正確的,由於某種原因它沒有正確發佈...... brb生病了修復 –

回答

1

~標誌沒有擴展到你的家目錄,所以你必須完整的絕對路徑手動傳遞到數據庫:

'NAME': '/home/yourname/django/bin/django_test/storage.db' 

如果django_test是你的Django項目的名稱,然後最好使用以下代碼:

'NAME': os.path.join(BASE_DIR, 'storage.db'), 
相關問題