2012-09-07 45 views
4

我正在使用amazon ec2和bitnami-djangostack ami部署我的django項目。將項目部署到bitnami後,django postgresql數據庫中的Relational DatabaseError

當我在本地開發應用程序時,我使用了mysql。但是在部署項目之後,我使用了默認的bitnami postgresql。

現在,我收到以下錯誤:

django.db.utils.DatabaseError: relation "appName_appName" does not exist 
LINE 1: SELECT (1) AS "a" FROM "appName_appName" WHERE "appName_a... 
         ^

我不知道爲什麼數據庫命名數據庫兩次(appName_appName)。

這裏是全終端:

[email protected]:/opt/bitnami/projects/Project$ sudo python manage.py syncdb 
/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/__init__.py:60: DeprecationWarning: Short names for ENGINE in database configurations are deprecated. Prepend default.ENGINE with 'django.db.backends.' 
    DeprecationWarning 
/opt/bitnami/projects/Project/cookbook/models.py:94: DeprecationWarning: A Field class whose db_type method hasn't been updated to take a `connection` argument. 
    class JSONField(models.TextField): 
Syncing... 
Creating tables ... 
Creating table auth_permission 
Creating table auth_group_permissions 
Creating table auth_group 
Creating table auth_user_user_permissions 
Creating table auth_user_groups 
Creating table auth_user 
Creating table auth_message 
Creating table django_content_type 
Creating table django_session 
Creating table django_site 
Creating table django_admin_log 
Creating table registration_registrationprofile 
Creating table south_migrationhistory 

You just installed Django's auth system, which means you don't have any superusers defined. 
Would you like to create one now? (yes/no): yesa 
Please enter either "yes" or "no": yes 
Username (Leave blank to use 'root'): xxxx 
E-mail address: xxxxx 
Password: xxx 
Password (again): xxx 
Traceback (most recent call last): 
    File "manage.py", line 14, in <module> 
    execute_manager(settings) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager 
    utility.execute() 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute 
    output = self.handle(*args, **options) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle 
    return self.handle_noargs(**options) 
    File "/opt/bitnami/python/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/management/commands/syncdb.py", line 90, in handle_noargs 
    syncdb.Command().execute(**options) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute 
    output = self.handle(*args, **options) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle 
    return self.handle_noargs(**options) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs 
    emit_post_sync_signal(created_models, verbosity, interactive, db) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal 
    interactive=interactive, db=db) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send 
    response = receiver(signal=self, sender=sender, **named) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/management/__init__.py", line 70, in create_superuser 
    call_command("createsuperuser", interactive=True) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/__init__.py", line 166, in call_command 
    return klass.execute(*args, **defaults) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute 
    output = self.handle(*args, **options) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 134, in handle 
    User.objects.create_superuser(username, email, password) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/models.py", line 140, in create_superuser 
    u = self.create_user(username, email, password) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/contrib/auth/models.py", line 136, in create_user 
    user.save(using=self._db) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/base.py", line 460, in save 
    self.save_base(using=using, force_insert=force_insert, force_update=force_update) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/base.py", line 570, in save_base 
    created=(not record_exists), raw=raw, using=using) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/dispatch/dispatcher.py", line 172, in send 
    response = receiver(signal=self, sender=sender, **named) 
    File "/opt/bitnami/projects/Project/cookbook/models.py", line 68, in create_cookbook_for_user 
    if created and not instance.cookbooks.exists(): 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/manager.py", line 192, in exists 
    return self.get_query_set().exists(*args, **kwargs) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/query.py", line 496, in exists 
    return self.query.has_results(using=self.db) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/sql/query.py", line 424, in has_results 
    return bool(compiler.execute_sql(SINGLE)) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql 
    cursor.execute(sql, params) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute 
    return self.cursor.execute(sql, params) 
    File "/opt/bitnami/apps/django/lib/python2.6/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute 
    return self.cursor.execute(query, args) 
django.db.utils.DatabaseError: relation "appName_appName" does not exist 
LINE 1: SELECT (1) AS "a" FROM "appName_appName" WHERE "appName_a... 
          ^

謝謝你, 凱蒂

+0

「數據庫命名數據庫兩次」 - >「django重複表名兩次」?另外,Django版本? –

+0

代碼中的函數create_cookbook_for_user有什麼作用?它看起來像是一個信號,這就是失敗發生的地方。 –

+0

當您加入該網站時,您(用戶)會獲得一本食譜。以便該函數創建與該用戶相關的cookbook實例 –

回答

0

我剛添加的appname_appname到我的數據庫,現在工作得很好。

抱歉誤導 - 我的錯誤。我仍然不明白爲什麼這段代碼沒有被添加到syncdb上的數據庫中,但是從開始。

但現在一切正常