2014-01-21 30 views
2

當我嘗試使用-auto功能進行新遷移時。 python manage.py schemamigration blogger --auto它表明:AttributeError:'TaggableManager'對象沒有屬性'primary_key'

You cannot use --auto on an app with no migrations. Try --initial. 

所以我在終端python manage.py schemamigration blogger --initial再次運行第一個遷移。我得到這個錯誤:

Traceback (most recent call last): 
    File "manage.py", line 10, in <module> 
    execute_from_command_line(sys.argv) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line 
    utility.execute() 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv 
    self.execute(*args, **options.__dict__) 
    File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute 
    output = self.handle(*args, **options) 
    File "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/management/commands/schemamigration.py", line 151, in handle 
    for action_name, params in change_source.get_changes(): 
    File "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/changes.py", line 460, in get_changes 
    model_defs = freeze_apps([self.migrations.app_label()]) 
    File "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py", line 32, in freeze_apps 
    frozen_models.update(model_dependencies(model)) 
    File "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py", line 96, in model_dependencies 
    depends.update(field_dependencies(field, checked_models)) 
    File "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/creator/freezer.py", line 132, in field_dependencies 
    value = get_attribute(field, attrname) 
    File "/usr/local/lib/python2.7/dist-packages/South-0.8.1-py2.7.egg/south/utils/__init__.py", line 38, in get_attribute 
    value = getattr(value, part) 
AttributeError: 'TaggableManager' object has no attribute 'primary_key' 

這是models.py的應用博客

from django.db import models 
from taggit.managers import TaggableManager 

# Create your models here. 
class Post(models.Model): 
    title = models.CharField(max_length=100) 
    body = models.TextField() 
    created = models.DateTimeField() 
    tags = TaggableManager() 

    def __unicode__(self): 
     return self.title 

回答

1

Taggit被稱爲混淆南他們甚至提到這個地方有文檔中的深跌。看看http://south.readthedocs.org/en/latest/customfields.html#field-name-patterns,看看它是否有幫助。

基本上你要告訴南忽略taggit使用類似:

from south.modelsinspector import add_ignored_fields 
add_ignored_fields(["^taggit\.managers"]) 
+1

,我再次得到了同樣的錯誤。在models.py中添加此步驟是否正確。或者我應該需要把它包含在別的地方。 – htoniv