Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django/South设置在python manage.py schemamigration testapp——initial上失败_Python_Django_Django South - Fatal编程技术网

Django/South设置在python manage.py schemamigration testapp——initial上失败

Django/South设置在python manage.py schemamigration testapp——initial上失败,python,django,django-south,Python,Django,Django South,我第一次尝试在我的开发环境中设置south。我以前已经安装了几个型号。South安装完成后,我按照South的文档转换我现有的应用程序 import datetime import urllib from django.db import models from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib

我第一次尝试在我的开发环境中设置south。我以前已经安装了几个型号。South安装完成后,我按照South的文档转换我现有的应用程序

import datetime
import urllib

from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin.util import quote
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from django.db import connection, transaction
"""
class BaseTable(models.Model):
    updated = models.DateTimeField(_('updated'), auto_now=True)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    is_active = models.BooleanField(_('active'), default=True)   

    class Meta:
        abstract = True
"""

class UserProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)
    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20, default="Dragons")
然而,我得到了下面的回溯。有什么想法吗

import datetime
import urllib

from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin.util import quote
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from django.db import connection, transaction
"""
class BaseTable(models.Model):
    updated = models.DateTimeField(_('updated'), auto_now=True)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    is_active = models.BooleanField(_('active'), default=True)   

    class Meta:
        abstract = True
"""

class UserProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)
    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20, default="Dragons")
多谢各位

./manage.py convert_to_south testapp
Creating __init__.py in '/home/testapp/../testapp/migrations'...
Traceback (most recent call last):
  File "./manage.py", line 14, in <module>
execute_manager(settings)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/management/commands/convert_to_south.py", line 70, in handle
management.call_command("schemamigration", app, initial=True, verbosity=verbosity)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/management/commands/schemamigration.py", line 140, in handle
    for action_name, params in change_source.get_changes():
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/creator/changes.py", line 444, in get_changes
    model_defs = freeze_apps([self.migrations.app_label()])
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/creator/freezer.py", line 35, in freeze_apps
    model_defs[model_key(model)] = prep_for_freeze(model)
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/creator/freezer.py", line 71, in prep_for_freeze
    fields = modelsinspector.get_model_fields(model, m2m=True)
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/modelsinspector.py", line 411, in get_model_fields
args, kwargs = introspector(field)
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/modelsinspector.py", line 371, in introspector
    kwargs[kwd] = get_value(field, defn)
  File "/usr/lib/python2.6/site-packages/South-0.7.6-py2.6.egg/south/modelsinspector.py", line 268, in get_value
    if "default" in options and value == options['default']:
  File "/usr/lib/python2.6/site-packages/django/db/models/fields/__init__.py", line 124, in __cmp__
    return cmp(self.creation_counter, other.creation_counter)
AttributeError: class NOT_PROVIDED has no attribute 'creation_counter'
import datetime
import urllib

from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin.util import quote
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from django.db import connection, transaction
"""
class BaseTable(models.Model):
    updated = models.DateTimeField(_('updated'), auto_now=True)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    is_active = models.BooleanField(_('active'), default=True)   

    class Meta:
        abstract = True
"""

class UserProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)
    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20, default="Dragons")

为了让South使用开始跟踪预先存在的表,您必须在安装syncdb后立即运行它。换句话说,您应该遵循以下步骤:

import datetime
import urllib

from django.db import models
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.admin.util import quote
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from django.db import connection, transaction
"""
class BaseTable(models.Model):
    updated = models.DateTimeField(_('updated'), auto_now=True)
    created = models.DateTimeField(_('created'), auto_now_add=True)
    is_active = models.BooleanField(_('active'), default=True)   

    class Meta:
        abstract = True
"""

class UserProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)
    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20, default="Dragons")
$ pip install south
$ nano settings.py
Add south to installed apps & save
$ python manage.py syncdb
$ python manage.py convert_to_south <app>
$pip安装南部
$nano settings.py
将south添加到已安装的应用程序并保存
$python manage.py syncdb
$python manage.py将\u转换为\u

意外单击“更新”可能是模型中有问题。你能发布代码吗?我至少有20个表已经在使用syncdb了。我只是想转学到南方,因为丢掉桌子和重新制作是件麻烦事。我已经删除了大部分模型代码以进行故障排除,剩下的就是这些。即使这样,我也得到了同样的精确追踪。我已经用模型代码更新了原始问题,因为注释不允许长文章。您是否尝试过schemamigration--init,然后迁移--false?是的--initial给了我同样的错误--fake没有任何作用。很抱歉反应太晚,但这些是我遵循的确切说明,我得到了上述错误。