本文介绍了Heroku创建了表,但是当我迁移时,他说没有创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Heroku中创建了syncdb(Python / Django应用程序),并创建了表south_migrationhistory,

I made syncdb (Python/Django application) in Heroku and he created table south_migrationhistory,

(venv-project)username@username:~/projectapp$ heroku run python manage.py syncdb
Running `python manage.py syncdb` attached to terminal... up, run.5529
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_session
Creating table django_site
Creating table django_admin_log
Creating table south_migrationhistory

(...)

Synced:
 > django.contrib.auth
 > django.contrib.contenttypes
 > django.contrib.sessions
 > django.contrib.sites
 > django.contrib.messages
 > django.contrib.staticfiles
 > django.contrib.admin
 > south

Not synced (use migrations):
 - core
 - galeria
(use ./manage.py migrate to migrate these)

但是当我迁移应用程序时,他表示没有创建表:

but when I'll migrate application he says that table wasn't created:

(venv-project)username@username:~/projectapp$ heroku run python manage.py migrate core
Running `python manage.py migrate core` attached to terminal... up, run.7542

(... monstruous log ...)

(...monstruous log...)

File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: no such table: south_migrationhistory

什么可以?谢谢。

编辑
解决了,我放入settings_local gitignore,从而识别出数据库postgres heroku。

EDIT:Solved, I put in settings_local gitignore and thereby recognized the database postgres heroku.

推荐答案

local_settings.py

import os

SITE_ROOT = os.path.dirname(__file__)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(SITE_ROOT, 'data.sqlite3'),
    }
}

在你的gitignore中添加: / p>

In your gitignore, add this:

project_name/local_settings.py
*.sqlite3

这篇关于Heroku创建了表,但是当我迁移时,他说没有创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 01:05