0
votes

I am working on a Django web app with south for db migration. I am quite new to south, and django as well. I tried using south with the official tutorials, however it failed with an exception: AttributeError: 'Options' object has no attribute 'index_together'. I run the south command like this:

python manage.py schemamigration southtut --initial  

The southtut models is this:

class Knight(models.Model):
    name = models.CharField(max_length=100)
    of_the_round_table = models.BooleanField()

My project models is this:

class Author(models.Model):
    name = models.CharField(max_length=64)
    authorId = models.CharField(max_length=32)

    def __unicode__(self):
        return self.name

    class Meta:
        db_table="Author"   

class Video(models.Model):
    videoId = models.CharField(max_length=32)
    videoUrl = models.URLField(max_length=200)
    author = models.ForeignKey(Author, null=True, related_name="videos", on_delete=models.SET_NULL)

    class Meta:
        db_table="Video"

class User(models.Model):
    token = models.CharField(max_length=50, null=True)
    favs = models.ManyToManyField(Video, related_name="fans", db_table="VideoUserR")

    class Meta:
        db_table = "User"

The whole error message I got is as below:

    Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 232, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/management/commands/schemamigration.py", line 151, in handle
    for action_name, params in change_source.get_changes():
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/creator/changes.py", line 460, in get_changes
    model_defs = freeze_apps([self.migrations.app_label()])
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/creator/freezer.py", line 37, in freeze_apps
    model_defs[model_key(model)] = prep_for_freeze(model)
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/creator/freezer.py", line 78, in prep_for_freeze
    fields['Meta'] = remove_useless_meta(modelsinspector.get_model_meta(model))
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/modelsinspector.py", line 441, in get_model_meta
    meta_def[kwd] = get_value(model._meta, defn)
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/modelsinspector.py", line 258, in get_value
    value = get_attribute(field, attrname)
  File "/Library/Python/2.7/site-packages/South-0.7.6-py2.7.egg/south/utils/__init__.py", line 38, in get_attribute
    value = getattr(value, part)
AttributeError: 'Options' object has no attribute 'index_together'  

Thanks

3
Can you post your models? - Paulo Bu
Sure, how could I send post the code here? or I could post the sample project to you. - user806135

3 Answers

6
votes

It's bug in south 0.8. Just update to 0.8.1 or newer and all be good.

1
votes

It looks like this is because you are trying to use index_together option in Meta section of your model. But this option is available only for django 1.5+ and i guess that you run it on a less recent version of django.

1
votes

I updated my django to 1.5.1, and this error disappeared. I have no idea how the 'index_together' come out, but since it is available in django 1.5.1, it get what it needs.