django-south

Django South - Create Not Null ForeignKey

做~自己de王妃 提交于 2019-12-20 16:53:24
问题 I have a Model class Mystery(models.Model): first = models.CharField(max_length=256) second = models.CharField(max_length=256) third = models.CharField(max_length=256) player = models.ForeignKey(Player) I added the player ForeignKey but when I try to migrate it using South it seems that I can't create this whith a null=False. I have this message : The field 'Mystery.player' does not have a default specified, yet is NOT NULL. Since you are adding this field, you MUST specify a default value to

Django South - Create Not Null ForeignKey

只愿长相守 提交于 2019-12-20 16:53:21
问题 I have a Model class Mystery(models.Model): first = models.CharField(max_length=256) second = models.CharField(max_length=256) third = models.CharField(max_length=256) player = models.ForeignKey(Player) I added the player ForeignKey but when I try to migrate it using South it seems that I can't create this whith a null=False. I have this message : The field 'Mystery.player' does not have a default specified, yet is NOT NULL. Since you are adding this field, you MUST specify a default value to

Squashing multiple South migrations into one migration

99封情书 提交于 2019-12-20 14:56:21
问题 During development I created many migrations, often going back and forth about how I wanted to implement something. Now it is time to push it to production, but I am getting errors when replaying all the migrations on the virgin database. I ended up doing the following to get it to work. python manage.py syncdb --all python manage.py migrate --fake But that will not apply a data migration that I created. Upon further thinking, I decided that I wanted to squash all my migrations into just one,

Squashing multiple South migrations into one migration

邮差的信 提交于 2019-12-20 14:56:14
问题 During development I created many migrations, often going back and forth about how I wanted to implement something. Now it is time to push it to production, but I am getting errors when replaying all the migrations on the virgin database. I ended up doing the following to get it to work. python manage.py syncdb --all python manage.py migrate --fake But that will not apply a data migration that I created. Upon further thinking, I decided that I wanted to squash all my migrations into just one,

What is a Django South GhostMigrations exception and how do you debug it?

有些话、适合烂在心里 提交于 2019-12-20 11:17:06
问题 Made some changes to my Django app's model and used South to migrate them on my development machine (migrations 0004 through 0009). But when trying to migrate these changes on the server, I get a "GhostMigrations" error. There isn't much good content explaining what a ghost migration is, or how to debug one. Google wasn't helpful on this one and the other SO questions mentioning ghost migrations don't cover this either (the most helpful question here was mostly about workflow). The helpful

Disable Django South when running unit tests?

萝らか妹 提交于 2019-12-20 11:02:43
问题 Disable Django South when running unit tests? How do you avoid running all of the south migrations when doing django unit testing? 回答1: Yes, the South documentation describes how to do it, but basically just add this to your settings.py file: SOUTH_TESTS_MIGRATE = False # To disable migrations and use syncdb instead SKIP_SOUTH_TESTS = True # To disable South's own unit tests 回答2: Even though, you have selected the good answer, I think that you should consider the option SOUTH_TESTS_MIGRATE

UUID field added after data already in database. Is there any way to populate the UUID field for existing data?

梦想与她 提交于 2019-12-20 10:28:30
问题 I've added a UUID field to some of my models and then migrated with South. Any new objects I create have the UUID field populated correctly. However the UUID fields on all my older data is null. Is there any way to populate UUID data for existing data? 回答1: For the following sample class: from django_extensions.db.fields import UUIDField def MyClass: uuid = UUIDField(editable=False, blank=True) name = models.CharField() If you're using South, create a data migration: python ./manage.py

South + Django 1.4 Database error

孤者浪人 提交于 2019-12-20 10:24:09
问题 I have just installed my Django project on a new system, and installed Django 1.4. However when I try to run manage.py runserver or manage.py syncdb I get this error from South: Validating models... Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x1a67810>> Traceback (most recent call last): File "/home/saul/.virtualenvs/canada/lib/python2.7/site-packages/django/core/management/commands

Adding new custom permissions in Django

纵然是瞬间 提交于 2019-12-20 07:59:24
问题 I am using custom permissions in my Django models like this: class T21Turma(models.Model): class Meta: permissions = (("can_view_boletim", "Can view boletim"), ("can_view_mensalidades", "Can view mensalidades"),) The problem is that when I add a permission to the list it doesn't get added to the auth_permission table when I run syncdb. What am I doing wrong. If it makes any difference I am using south for database migrations. 回答1: South does not track django.contrib.auth permissions. See

South migrate DateField to IntegerField

喜夏-厌秋 提交于 2019-12-20 02:54:27
问题 I want to change my Model class Source(models.Model): release_date = models.DateField() to class Source(models.Model): release_date = models.IntegerField() as expected, I get an error django.db.utils.DataError: (1264, "Out of range value for column 'release_date' at row 1") What I actually want is, to only save the year in the IntegerField as that is all I need. Is there a very intelligent way to take existing dates' year field and migrate it to the new IntegerField by altering the method def