I was wondering if the following migration is possible with Django south and still retain data.
Before:
I currently have two apps, one called tv, one called movies, each with a VideoFile model (simplified here):
tv/models.py:
class VideoFile(models.Model):
show = models.ForeignKey(Show, blank=True, null=True)
name = models.Ch...
I kept thinking a lot about the meaning of migrating a Django app the last few days and heard about migrating Django apps with django-south. Maybe it's just the lack of sufficient English skills (as English is not my native language) or this is one of the things you confront in a programmer's life which are so simple, that it takes a gen...
I have a migration:
...
def forwards(self, orm):
for p in products.models.Product.objects.all():
new = cart.models.Product(title = p.title)
new.save()
def backwards():
...
But when I run migrate it runs through the loop twice.
...
I've been working on a Django project using South to track and manage database schema changes. I'm starting a new Java project using Google Web Toolkit and wonder if there is an equivalent tool. For those who don't know, here's what South does:
Automatically recognize changes to my Python database models (add/delete columns, tables etc...
Hi,
I was using python 2.5 and django 1.0.2. But I moved to python 2.6 and django 1.2 recently and I'm getting the following error now during the migrate:
alex@alex-desktop:~/server/mx30$ python manage.py migrate
Running migrations for peer_center:
- Migrating forwards to 0005_adding_config_model.
> peer_center: 0001_initial
> peer...
I'm working with a legacy database which uses the MySQL big int so I setup a simple custom model field to handle this:
class BigAutoField(models.AutoField):
def get_internal_type(self):
return "BigAutoField"
def db_type(self):
return 'bigint AUTO_INCREMENT' # Note this won't work with Oracle.
This works fine w...
I've got a Django project on my machine and when I try to use South to migrate the data schema, I get several odd errors. Example:
$ python manage.py convert_to_south thisLocator
/Library/Python/2.6/site-packages/registration/models.py:4: DeprecationWarning: the sha >module is deprecated; use the hashlib module instead
import...
I'm using Django 1.2 trunk with South 0.7 and an AutoOneToOneField copied from django-annoying. South complained that the field does not have rules defined and the new version of South no longer has an automatic field type parser. So I read the South documentation and wrote the following definition (basically an exact copy of the OneToOn...
I have been using South on my project for a while, but I recently did a huge amount of development and changed development machine and I think something messed up in the process. The project works fine, but I can't apply migrations. Whenever I try to apply a migration I get the following traceback:
danpalmer:pest Dan$ python manage.py m...
Does django-reversion work well with south migrations?
Are django-reversion and south compatible?
Current versions:
- reversion - 1.2.1
- south - 0.7.1
...
After a migration with south, I ended up deleting a column. Now the current data in one of my tables is screwed up and I want to delete it, but attempts to delete just result in an error:
>>> d = Degree.objects.all()
>>> d.delete()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python26\lib\site-p...
I've create a custom field "Private FileField". I'm not able to get it to work with django-south.
My understanding of South field rules is based on
http://south.aeracode.org/docs/tutorial/part4.html#tutorial-part-4 and
http://south.aeracode.org/docs/customfields.html
Relevant snippets are:
class FileField(models.CharField):
__meta...
I'M using django south on a bigger project, the only thing I don't like about it, that you can't create schemamigrations for all of your apps at once (I have a lot of apps that inherit from the same abstract model, if I change that base model there are alot of apps to migrate) - thought you can actually migrate all of them at once (usin...
I would like to preserve past revisions of MyModel instances, while updating and migrating MyModel with south.
Is it possible to update the past revisions?
Is it necessary to update the revisions on all types of changes to the model?
What kind of changes, if any, will force me to erase the revision history no matter what?
Is there an el...
I would like to change a name of specific fields in a model:
class Foo(models.Model):
name = models.CharField()
rel = models.ForeignKey(Bar)
should change to:
class Foo(models.Model):
full_name = models.CharField()
odd_relation = models.ForeignKey(Bar)
What's the easiest way to do this using South?
...
Instead of using django's auth module I've used my own and already regret it a lot.
In an effort to rectify the situation, I'm trying to migrate the data from my User model to django.auth.models.User.
I've created a data migration as follows:
def forwards(self, orm):
"""Migrate user information from mooi User model to auth User mo...
I'm writing a data migration in south to fix some denormalized data I screwed up in earlier code. The way to figure out the right value for the incorrect field is to call a static method on the django model class. The code looks like this:
class Account(models.Model):
name = models.CharField()
@staticmethod
def lookup_by_...
I have a custom app which I wanted to start using South with. It uses a FK for associating a blog entry from another app (proprietary, not written by me). Problem is when I try to run the initial schemamigration I get an error that some of the blog entry app's fields cannot be frozen. The fields that can't be frozen are fields that us...
Renaming a simple charfield etc seems easy (http://stackoverflow.com/questions/3235995/django-how-to-rename-a-model-field-using-south)
However when I try using the same on a ForeignKey field I get an error:
_mysql_exceptions.OperationalError: (1091, "Can't DROP '[new_fkey_field_name]'; check that column/key exists")
Which stems from...
I have a django project with a database table that already contains data. I'd like to change the field name without losing any of the data in that column. My original plan was to simply change the model field name in a way that would not actually alter the name of the db table (using the db_column column parameter):
The original model...