我的第一个Mezzanine项目中的共享主机

时间:2015-12-03 18:29:35

标签: mysql django shared-hosting dreamhost mezzanine

我试图在Dreamhost的共享主机中使用Mezzanine cms(3.1.4)。我成功创建了我的第一篇博文,但奇怪的是,我找不到与此条目相关的表格。 Dreamhost的Phpadmin页面确实显示了我的夹层数据库(名为hamlet),但其中只有10个表:

auth_group, auth_group_permissions,auth_permission, auth_user, auth_user_groups, auth_user_user_permissions
django_admin_log, django_content_type, django_migrations, django_session    

没有博客表。有人对此有解释吗?

编辑:我做的步骤:

- 在我的虚拟环境中进入env.mez

处理了passenger_wsgi.py文件:

import sys, os
INTERP = "/home/geantbrun/opt/python-2.7.7/bin/python"
#INTERP is present twice so that the new python interpreter knows the actual executable path
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)

cwd = os.getcwd()
sys.path.append(cwd)
sys.path.append(cwd + '/mez')  #You must add your project here

sys.path.insert(0,cwd+'/env.mez/bin')
sys.path.insert(0,cwd+'/env.mez/lib/python2.7/site-packages/mezzanine')
sys.path.insert(0,cwd+'/env.mez/lib/python2.7/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = "mez.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

在Dreamhost面板上处理数据库小队

- 处理我的夹层项目(mez)

- 在settings.py中设置参数:

DATABASES = {
"default": {
    "ENGINE": "django.db.backends.mysql",
    "NAME": "hamlet",
    "USER": "(myusername)",
    "PASSWORD": "(mypass)",
    "HOST": "mysql.geantbrun.com",
    "PORT": "3306",
}

}

收集静态文件

-Command syncdb:     python manage.py syncdb

Syncing...
Creating tables ...
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_redirect
Creating table django_session
Creating table django_site
Creating table south_migrationhistory
Creating table django_admin_log
Creating table django_comments
Creating table django_comment_flags

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): yes
Username (leave blank to use 'geantbrun'): 
Email address: 
Password: 
Password (again): 
Superuser created successfully.

A site record is required.
Please enter the domain and optional port in the format 'domain:port'.
For example 'localhost:8000' or 'www.example.com'. 
Hit enter to use the default (127.0.0.1:8000): (mysite.com)

Creating default site record: mysite.com ... 

Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

Synced:
   > mezzanine.boot
   > moderna
  > django.contrib.auth
  > django.contrib.contenttypes
  > django.contrib.redirects
  > django.contrib.sessions
  > django.contrib.sites
  > django.contrib.sitemaps
  > django.contrib.staticfiles
  > compressor
  > filebrowser_safe
  > south
  > django.contrib.admin
  > django.contrib.comments

 Not synced (use migrations):
  - mezzanine.conf
  - mezzanine.core
  - mezzanine.generic
  - mezzanine.blog
  - mezzanine.forms
  - mezzanine.pages
  - mezzanine.galleries
  - mezzanine.twitter
 (use ./manage.py migrate to migrate these)

- 此时,在Dreamhost面板上,我看到现在在hamlet数据库(auth_,django_和south_migrationhistory表)中创建了14个表。

-Migrate命令:python manage.py migrate

Running migrations for conf:
 - Migrating forwards to 0004_ssl_account_settings_rename.
 > conf:0001_initial
 > conf:0002_auto__add_field_setting_site
 > conf:0003_update_site_setting
 - Migration 'conf:0003_update_site_setting' is marked for no-dry-run.
 > conf:0004_ssl_account_settings_rename
 - Migration 'conf:0004_ssl_account_settings_rename' is marked for no-dry-run.
 - Loading initial data for conf.
Installed 0 object(s) from 0 fixture(s)
Running migrations for core:
 - Migrating forwards to 0006_initial.
 > core:0001_initial
(...other migrations)
 > core:0006_initial
FATAL ERROR - The following SQL query failed: CREATE TABLE    "core_sitepermission" ("id" integer NOT NULL PRIMARY KEY, "user_id" integer NOT NULL)
The error was: table "core_sitepermission" already exists
 ! Error found during real run of migration! Aborting.

Error in migration: core:0006_initial

Traceback (most recent call last):
File "manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
(...other traces)
  File "/home/geantbrun/mysite.com/env.mez/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 452, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: table "core_sitepermission" already exists

请注意,最后一行引用的文件是... / backends / sqlite3 / base.py。我意识到DATABASES参数可能被local_settings文件覆盖。我从local_settings中删除了DATABASES参数,然后重新运行migrate命令。结果:

Error in migration: core:0006_initial
Traceback (most recent call last):
  File "manage.py", line 29, in <module>
    execute_from_command_line(sys.argv)

  File "/home/geantbrun/mysite.com/env.mez/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 124, in execute
      return self.cursor.execute(query, args)
    File "/home/geantbrun/mysite.com/env.mez/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
      self.errorhandler(self, exc, value)
    File "/home/geantbrun/mysite.com/env.mez/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
      raise errorclass, errorvalue
  django.db.utils.OperationalError: (1050, "Table 'core_sitepermission' already exists")

不再提及sqlite3,但最后会出现同样的错误(&#39; core_sitepermission已经存在&#39;)。是否应该使用--fake参数运行migrate命令,因为数据库已经创建了?

0 个答案:

没有答案