Issue using South

6 views
Skip to first unread message

jul

unread,
Apr 28, 2010, 5:41:55 AM4/28/10
to django-multilingual
Hi,

I'm using South to migrate my models (shown at the end of the message)
that include multilingual fields. I applied the patch given in
http://code.google.com/p/django-multilingual/issues/detail?id=111.
When doing the first migration I get an error. Below are the messages
I got doing the syncdb, the schemamigration --initial, and the first
migration.

Anybody can help?

Thanks
Jul


****************syncdb****************

xxx@xxx:~/atable$ python manage.py syncdb;
Syncing...
Creating table south_migrationhistory

Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.comments
> django.contrib.sites
> django.contrib.admin
> registration
> djapian
> resto
> multilingual
> south

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


****************schemamigration --initial****************

xxx@xxx:~/atable$ python manage.py schemamigration --initial resto
Creating migrations directory at '/home/jul/atable/resto/
migrations'...
Creating __init__.py in '/home/jul/atable/resto/migrations'...
+ Added model resto.ContinentTranslation
+ Added unique constraint for ['language_id', 'master'] on
resto.ContinentTranslation
+ Added unique constraint for ['language_id', 'name'] on
resto.ContinentTranslation
+ Added model resto.Continent
+ Added model resto.CountryTranslation
+ Added unique constraint for ['language_id', 'master'] on
resto.CountryTranslation
+ Added unique constraint for ['language_id', 'name'] on
resto.CountryTranslation
+ Added model resto.Country
+ Added model resto.CityTranslation
+ Added unique constraint for ['language_id', 'master'] on
resto.CityTranslation
+ Added model resto.City
+ Added model resto.CategoryTranslation
+ Added unique constraint for ['language_id', 'master'] on
resto.CategoryTranslation
+ Added model resto.Category
+ Added M2M table for parent on resto.Category
+ Added model resto.Tag
+ Added model resto.Restaurant
+ Added M2M table for category on resto.Restaurant
+ Added M2M table for tag on resto.Restaurant
+ Added model resto.Comment
+ Added model resto.Meal
+ Added model resto.Favorite
+ Added unique constraint for ['user', 'restaurant'] on
resto.Favorite
+ Added model resto.Rating
Created 0001_initial.py. You can now apply this migration with: ./
manage.py migrate resto


****************error when migrating****************

xxx@xxx:~/atable$ python manage.py migrate resto
Running migrations for resto:
- Migrating forwards to 0001_initial.
> resto:0001_initial
! Error found during real run of migration! Aborting.

! Since you have a database that does not support running
! schema-altering statements in transactions, we have had
! to leave it in an interim state between migrations.

! You *might* be able to recover with: = DROP TABLE
`resto_continent_translation` CASCADE; []
= DROP TABLE `resto_continent` CASCADE; []
= DROP TABLE `resto_country_translation` CASCADE; []
= DROP TABLE `resto_country` CASCADE; []
= DROP TABLE `resto_city_translation` CASCADE; []
= DROP TABLE `resto_city` CASCADE; []
= DROP TABLE `resto_category_translation` CASCADE; []
= DROP TABLE `resto_category` CASCADE; []
= DROP TABLE `resto_category_parent` CASCADE; []
= DROP TABLE `resto_tag` CASCADE; []
= DROP TABLE `resto_restaurant` CASCADE; []
= DROP TABLE `resto_restaurant_category` CASCADE; []
= DROP TABLE `resto_restaurant_tag` CASCADE; []
= DROP TABLE `resto_comment` CASCADE; []
= DROP TABLE `resto_meal` CASCADE; []
= DROP TABLE `resto_favorite` CASCADE; []
= DROP TABLE `resto_rating` CASCADE; []

! The South developers regret this has happened, and would
! like to gently persuade you to consider a slightly
! easier-to-deal-with DBMS.


Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/var/lib/python-support/python2.5/django/core/management/
__init__.py", line 362, in execute_manager
utility.execute()
File "/var/lib/python-support/python2.5/django/core/management/
__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/lib/python-support/python2.5/django/core/management/
base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/var/lib/python-support/python2.5/django/core/management/
base.py", line 222, in execute
output = self.handle(*args, **options)
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/management/
commands/migrate.py", line 102, in handle
delete_ghosts = delete_ghosts,
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
__init__.py", line 202, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
migrators.py", line 215, in migrate_many
result = migrator.__class__.migrate_many(migrator, target,
migrations, database)
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
migrators.py", line 284, in migrate_many
result = self.migrate(migration, database)
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
migrators.py", line 121, in migrate
result = self.run(migration)
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
migrators.py", line 95, in run
return self.run_migration(migration)
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
migrators.py", line 77, in run_migration
migration_function()
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/migration/
migrators.py", line 56, in <lambda>
return (lambda: direction(orm))
File "/home/jul/atable/resto/migrations/0001_initial.py", line 16,
in forwards
('name', self.gf('django.db.models.fields.CharField')
(max_length=100)),
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/db/generic.py",
line 210, in create_table
', '.join([col for col in columns if col]),
File "/home/jul/lib/python/South-0.7-py2.5.egg/south/db/generic.py",
line 134, in execute
cursor.execute(sql, params)
File "/var/lib/python-support/python2.5/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
File "/var/lib/python-support/python2.5/django/db/backends/mysql/
base.py", line 84, in execute
return self.cursor.execute(query, args)
File "/var/lib/python-support/python2.5/MySQLdb/cursors.py", line
166, in execute
self.errorhandler(self, exc, value)
File "/var/lib/python-support/python2.5/MySQLdb/connections.py",
line 35, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1050, "Table
'resto_continent_translation' already exists")



****************models.py****************

class Continent(models.Model):

code = models.CharField(max_length=5, primary_key=True)

class Translation(multilingual.Translation):
name = models.CharField(max_length=100, unique=True)

def __unicode__(self):
return self.name


class Country(models.Model):

code = models.CharField(max_length=5, primary_key=True)

continent = models.ForeignKey(Continent)

class Translation(multilingual.Translation):
name = models.CharField(max_length=100, unique=True)

class Meta:
verbose_name_plural = 'Countries'

def __unicode__(self):
return self.name


class City(models.Model):

country = models.ForeignKey(Country)

geonameID = models.PositiveIntegerField(unique=True)

class Translation(multilingual.Translation):
name = models.CharField(max_length=100)

class Meta:
verbose_name_plural = 'Cities'

def __unicode__(self):
return self.name

CATEGORY_TYPE = [
(1, 'region'),
(2, 'type'),
]


class Category(models.Model):

parent = models.ManyToManyField('self', symmetrical=False,
null=True, blank=True)

type = models.PositiveSmallIntegerField(choices=CATEGORY_TYPE)

class Translation(multilingual.Translation):
name = models.CharField(max_length=100)

class Meta:
verbose_name_plural = 'Categories'

def __unicode__(self):
if (self.name_en=="Other"):
return "%s-%s" %(self.parent.all()[0].name, self.name)
else:
return "%s" %(self.name)


class Tag(models.Model):

name = models.CharField(max_length=100, unique=True)

class Meta:
ordering = ['name']

def __unicode__(self):
return self.name


PRICE_RANGES = [
(1, u'<15\u20ac'),
(2, u'15-30\u20ac'),
(3, u'30-60\u20ac'),
(4, u'>60\u20ac'),
]

PRICE_RANGES_AND_EMPTY = [('',_("All"))] + PRICE_RANGES

class Restaurant(models.Model):
name = models.CharField(max_length=50)
country=models.ForeignKey(Country)
city=models.ForeignKey(City)
street=models.CharField(max_length=50)
street_number=models.PositiveSmallIntegerField(max_length=10)
postal_code=models.PositiveIntegerField(max_length=10,blank=True,
null=True)
latitude=models.FloatField()
longitude=models.FloatField()
mean_rating=models.FloatField(blank=True, null=True)
phone_number=models.CharField(max_length=16, blank=True,
null=True)
url=models.CharField(max_length=50, blank=True, null=True)
price_range=models.PositiveSmallIntegerField(choices=PRICE_RANGES)
category=models.ManyToManyField(Category)
tag=models.ManyToManyField(Tag, blank=True, null=True)
slug = models.SlugField(unique=True)

def get_absolute_url(self):
return "/restaurant/%s/" % self.slug


def __unicode__(self):
return self.name

def save(self):
unique_slugify(self, self.name)
super(Restaurant, self).save()


class Comment(models.Model):

user = models.ForeignKey(User)
restaurant = models.ForeignKey(Restaurant)
submit_date = models.DateTimeField(blank = True, null = False)
comment = models.TextField()
language = models.CharField(max_length=5, blank=True, null=True)

def __unicode__(self):
return self.comment


class Meal(models.Model):

user = models.ForeignKey(User)
restaurant = models.ForeignKey(Restaurant)
submit_date = models.DateTimeField(blank = True, null = False)
price = models.PositiveSmallIntegerField(blank=True, null=True)
meal = models.TextField()
language = models.CharField(max_length=5, blank=True, null=True)

def __unicode__(self):
return self.meal


class Favorite(models.Model):

user = models.ForeignKey(User)
restaurant = models.ForeignKey(Restaurant)

class Meta:
unique_together = ("user", "restaurant")

def __unicode__(self):
return u'%s is one of %s\'s favorites' % (self.restaurant,
self.user)


class Rating(models.Model):

user = models.ForeignKey(User)
restaurant = models.ForeignKey(Restaurant)
value = models.PositiveSmallIntegerField()

def save(self):
r = self.restaurant
ratings = Rating.objects.filter(restaurant=r)
r.mean_rating = float(sum(ratings.values_list('value',
flat=True))+int(self.value))/(len(ratings)+1)
r.save()
super(Rating, self).save()

def __unicode__(self):
return u'%s rated %s a %s' % (self.user, self.restaurant,
self.value)

--
You received this message because you are subscribed to the Google Groups "django-multilingual" group.
To post to this group, send email to django-mu...@googlegroups.com.
To unsubscribe from this group, send email to django-multilin...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-multilingual?hl=en.

Reply all
Reply to author
Forward
0 new messages