django-south

Django/South: What is the proper way to set related_name arguments for the intermediate model on a ManyToMany to self relation?

≯℡__Kan透↙ 提交于 2019-12-24 10:56:42
问题 This is related to a question I asked yesterday about migrating a change from a ForeignKey to self to a ManyToManyField to self, however because I'm only prototyping an app for the time being/due to time constraints, I've decided to just drop the relevant tables and reset the migration history. These are the relevant models/fields: class Person(models.Model): nominator = models.ManyToManyField('self', symmetrical=False, verbose_name=_('nominator'), through='Nomination', null=True, blank=True)

Django South: How can I access models in sub-packages in migrations

浪尽此生 提交于 2019-12-24 03:19:37
问题 Since our app has many models, we place them in sub-packages of the models packages, i.e. the Cheddar model would not be in models.Cheddar , but instead in models.cheese.Cheddar . It seems I cannot access these models in a South datamigration, even though I created an models/__init__.py as per this answer containing the line from cheese import * . In my data migration file, the line for cheddar in orm.Cheddar.objects.all(): still causes the following error: AttributeError: The model 'Cheddar'

Django, south, postgres initial migration error

痞子三分冷 提交于 2019-12-24 00:06:10
问题 I am using south and django on a new site with a postgres database. I am attempting to do the initial migration but get the following error django.db.utils.DatabaseError: invalid input syntax for integer: "" when this line is called ('views', self.gf('django.db.models.fields.IntegerField')(default=0)), which translates to this in the model views = models.IntegerField(default=0) This all works fine with sqllite locally, anyone know why this is happening? 回答1: As you mentioned in your comments,

What's the Django 1.7+ equivalent to South's add_ignored_fields()?

為{幸葍}努か 提交于 2019-12-23 22:24:59
问题 Back in previous versions of Django, we all used South to do migrations, and because it wasn't as smart as we might have liked, we sometimes needed to tell it to explicitly ignore some fields because such fields were too complicated for it to handle. We did this with add_ignored_fields and everything pretty much worked. In our case, we have a "field" on our model that's a subclass of CharField that actually attaches two additional fields to the model via the contribute_to_class method. It's

South migration: delete all migration files (00*_*) and start from 0001, while keeping the original data

时光总嘲笑我的痴心妄想 提交于 2019-12-23 17:13:00
问题 I am developing web systems using Django and they are deployed on Heroku. After the system goes production, all database data and the migration files (i.e., the 00*_* files) have to be retained. The followings are my procedure to perform database migration and deployment: For the first deployment, perform manage.py makemigrations locally and push to Heroku. Perform manage.py migrate on Heroku. If models are changed later: Perform makemigrations locally and push to Heroku. Perform migrate on

from django.db import models, migrations ImportError: cannot import name migrations

核能气质少年 提交于 2019-12-23 06:56:54
问题 So I've started to experience some issues with south on my Django web server. Migrate command is failing with this output everytime: from django.db import models, migrations ImportError: cannot import name migrations (Above this the error displays the rout to the file that failed to be migrated) My Django version is 1.5.1, while my south version is 0.8.4 The thing that troubles me the most is that the module django.db.migrations is nowhere to be found. Any ideas? 回答1: Migrations were

Django South Error: AttributeError: 'DateTimeField' object has no attribute 'model'`

限于喜欢 提交于 2019-12-23 06:49:17
问题 So I'm trying to migrate a table by adding two columns to it. A startDate and an endDate . Using south for Django, this should be a simple migrate. I have loads of other tables with dateTimes in them as well, but for some reason I'm getting and issue here and I don't see it. The stack trace is stating: AttributeError: 'DateTimeField' object has no attribute 'model' Here is the model I am migrating: # Keep track of who has applied for a Job class JobApply(models.Model): job = models.ForeignKey

DROP CASCADE in Sql Server

☆樱花仙子☆ 提交于 2019-12-22 10:12:31
问题 I'm running a South migration in a Django project that uses Sql Server and pyodbc. This is backwards migration so the South is trying to delete a few of my tables. The South executes the following method in order to drop the tables: def delete_table(self, table_name, cascade=True): """ Deletes the table 'table_name'. """ params = (self.quote_name(table_name), ) if cascade: self.execute('DROP TABLE %s CASCADE;' % params) else: self.execute('DROP TABLE %s;' % params) drop_table = alias('delete

Problem installing South on existing database. MySql doesn't support 'schema-altering statements'

会有一股神秘感。 提交于 2019-12-22 09:18:18
问题 I have a django project with an existing db that I would really like to avoid dumping or interrupting. I am attempting to install South but when I run my initial migration python manage.py migrate example I get the following error: Running migrations for example: - Migrating forwards to 0001_initial. > example: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 !

Does South handle model mixins?

谁说我不能喝 提交于 2019-12-22 09:07:04
问题 I've created a mixin and inherited from it in some models. The problem is when I create a schema migration, the mixin's fields are there. class MyMixin(object): a_field = models.CharField(max_length=30, blank=True) another_field = models.DateTimeField(blank=True, null=True) class Meta: abstract = True class MyModel(models.Model, myMixin): ... Any ideas? 回答1: Seem to have got it working using the following class MyMixin(models.Model): a_field = models.CharField(max_length=30, blank=True)