django-south

Django South – Migrate From Python Code

Django South – Migrate From Python Code Question: Is it possible to run a migration from Python code? I don’t want to (actually I cannot) use the terminal command: venv/bin/python src/manage.py migrate myapp I need to run it from Python code as part of my business logic on a dynamically created database. This is what …

Total answers: 2

Can you migrate backwards to before the first migration in South?

Can you migrate backwards to before the first migration in South? Question: Can you migrate an app backwards to before its first migration in Django South? If not, are there plans to add such functionality, perhaps using an option passed to migrate? Asked By: CJ Gaconnet || Source Answers: ./manage.py migrate myapp zero See: https://docs.djangoproject.com/en/1.9/ref/django-admin/#migrate …

Total answers: 1

Why don't my south migrations work?

Why don't my south migrations work? Question: First, I create my database. create database mydb; I add “south” to installed Apps. Then, I go to this tutorial: http://south.aeracode.org/docs/tutorial/part1.html The tutorial tells me to do this: $ py manage.py schemamigration wall –initial >>> Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate wall Great, …

Total answers: 6

How to call a static methods on a django model class during a south migration

How to call a static methods on a django model class during a south migration Question: 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 …

Total answers: 3

Django – How to rename a model field using South?

Django – How to rename a model field using South? Question: 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? Asked By: Jonathan …

Total answers: 6

Easiest way to rename a model using Django/South?

Easiest way to rename a model using Django/South? Question: I’ve been hunting for an answer to this on South’s site, Google, and SO, but couldn’t find a simple way to do this. I want to rename a Django model using South. Say you have the following: class Foo(models.Model): name = models.CharField() class FooTwo(models.Model): name = …

Total answers: 4

What is the best approach to change primary keys in an existing Django app?

What is the best approach to change primary keys in an existing Django app? Question: I have an application which is in BETA mode. The model of this app has some classes with an explicit primary_key. As a consequence Django use the fields and doesn’t create an id automatically. class Something(models.Model): name = models.CharField(max_length=64, primary_key=True) …

Total answers: 10

Using south to refactor a Django model with inheritance

Using south to refactor a Django model with inheritance Question: 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 = …

Total answers: 4