django-south

Using south to refactor a Django model with inheritance

夙愿已清 提交于 2019-12-17 15:06:46
问题 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.CharField(max_length=1024, blank=True) size = models.IntegerField(blank=True, null=True) ctime = models.DateTimeField(blank=True, null=True) movies/models.py: class

How to reset migrations in Django 1.7

谁都会走 提交于 2019-12-17 10:21:46
问题 (I know there is a title the same as this, but the question is different). I have managed to get my development machine migrations and production migrations out of sync. I have a Django app which was using South. I had my own workflow that worked fine (it probably wasn't the correct way to do things, but I had no problems with it). Basically I have a script that copies the production database dump to my development machine. It also copied the migration files. That way the two were in synch,

django 1.7 migrate gets error “table already exists”

十年热恋 提交于 2019-12-17 10:19:03
问题 I am trying to apply a migration but am getting the error: django.db.utils.OperationalError: (1050, "Table 'customers_customer' already exists") I get this by issuing the following command: python manage.py migrate My customer table already exists, so what do I do to let the migration know this, not error out, and run my modification to my model? I ran this on my local environment with local database with no problem. It is when I pointed my database to production and ran migrate above that I

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

孤街醉人 提交于 2019-12-17 07:17:44
问题 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) I think that it was a bad idea (see unicode error when saving an object in django admin) and I would like to move back and have an id for every class of my model. class Something(models.Model): name = models

syncdb = Error: One or more models did not validate

你。 提交于 2019-12-12 05:27:08
问题 When I do manage.py syncdb I get: Error: One or more models did not validate: users.userprofile: "uuid": Primary key fields cannot have null=True. even though my class UserProfile(models.Model) have: uuid = UUIDField(primary_key=True, auto=True, editable=False) 回答1: The comment from Daniel was probably it, I just didn't know how to follow the clue. The fix, that came from Joshua, was to remove the official django-uuidfield 's and replace them with Joshua's fork. -django-uuidfield==0.4 -django

Django, South, and Guardian: Migrate

删除回忆录丶 提交于 2019-12-12 05:18:23
问题 I have two users, mh00h1 and mh00h2. I also have modelA that defines the following in my models.py: class Meta: permissions = ( ('read','read'), ('write','write'), ) From a shell, I went to set permissions: >>>> frhde = create modelA instance >>>> assign_perm('read', mh00h2, frhde) DoesNotExist: Permission matching query does not exist. Lookup parameters were {'codename': u'read', 'content_type': <ContentType: modelA>} I realized that South didn't migrate my models after I added class Meta to

Django South migration is throwing an error 'module' object has no attribute 'SET_NULL'

自作多情 提交于 2019-12-12 04:46:54
问题 I just generated the migration scripts through ./manage.py schemamigration --auto and ran it. I get the following error. I am stumped as to what it could mean. I have been using SET_NULL for a while now. So this is something new that didn't occur earlier. Any idea what could be wrong? Traceback (most recent call last): File "./manage.py", line 16, in execute_from_command_line(sys.argv) File "/home/vivekv/.environments/fantain/local/lib/python2.7/site-packages/django/core/management/ init .py"

South manages a new app instead of syncdb

寵の児 提交于 2019-12-12 02:32:05
问题 I've added a new app (specifically tastypie) and tried to syncdb however South won't let me. I get: Not synced (use migrations): - tastypie Why would South insist on this while I didn't use manage.py convert_to_south tastypie ? 回答1: South manages any app that has a /migrations folder under it. Many 3rd party apps come with migrations built in, if you have south then those migrations are used if not then syncdb runs and you're good to go. convert_to_south is a bit of a hack IMO. It essentially

Couldn't load fixtures with South in Django project

十年热恋 提交于 2019-12-11 09:29:34
问题 I've Django project which is using South application to handle schema and data migration. In one of my applications I have migration (number 0004) which is responsible for loading data fixtures from json file: class Migration(DataMigration): def forwards(self, orm): from django.core.management import call_command call_command("loaddata", "dummy_data.json") In the same project I try to add functionality of 'soft delete' which needs adding one more filed, defined as: deleted_at = models

South migrations and changes to many-to-may fields

牧云@^-^@ 提交于 2019-12-11 07:32:01
问题 I was working on an app that is supposed to send newsletters to customers. I had a model defined like this from django.auth.models import User class Newsletter(models.Model): owner = models.ForeignKey(User, related_name='+', blank=False) sent = models.BooleanField(default=False) date_created = models.DateTimeField(auto_now_add=True) date_sent = models.DateTimeField(null=True) subject = models.CharField(max_length=255) content = HTMLField() recipients = models.ManyToManyField(User, related