django-south

DROP CASCADE in Sql Server

我的梦境 提交于 2019-12-06 03:23:10
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_table') The problem is that the Sql Server does not support cascade drops, so the migration fails with

Consolidating Django South Migrations

我是研究僧i 提交于 2019-12-06 00:21:01
问题 In the initial stages of my project I'm making a lot of changes to the models and thus I've ended up with a lot of south migrations being generated for my apps. Is it possible to consolidate them in any way before going to my production server to perform the migrations so I don't have like a million migrations for each app? And if so, how would I go about doing that? 回答1: You could always delete the existing migrations and create a new "initial" migration. To do this, you will need to: Remove

Django Proxy Model Permissions Do Not Appear

爱⌒轻易说出口 提交于 2019-12-05 17:35:28
问题 I extended Django admin site for my app to allow non-staff/superusers access. This is working just fine. I created a proxy model for an existing model and registered it to my admin site, however, it doesn't appear for non-staff users. From the documentation I read, my understanding is that proxy models get their own permissions. I checked and these don't appear in the list of available permissions. Here's my code in case it helps: Normal Model class Engagement(models.Model): eng_type = models

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

懵懂的女人 提交于 2019-12-05 14:41:01
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 ! to leave it in an interim state between migrations. ! You *might* be able to recover with: = DROP TABLE

Django south: changing field type in data migration

点点圈 提交于 2019-12-05 11:53:06
问题 I'm changing a field from CharField to IntegerField . The field name remains the same. The newly created field will be based off the old field. For example, if the old field was "L", it would have the number "1" instead. How can I accomplish this in the forwards() function? 回答1: The correct way to do it would be to break this into three migrations: A first schema migration to add the new IntegerField field. Followed by a data migration to convert the data originating from the CharField to the

south migration: “database backend does not accept 0 as a value for AutoField” (mysql)

南楼画角 提交于 2019-12-05 09:57:56
问题 I'm new to django and trying to have a Foreign key back to users for an assignee and reporter. But when i'm trying to apply the change with South i get the error ValueError: The database backend does not accept 0 as a value for AutoField. My Model Code: class Ticket(models.Model): title = models.CharField(max_length=80) text = models.TextField(blank=True) prioritys = models.ForeignKey(Prioritys) ticket_created = models.DateTimeField(auto_now_add=True) ticket_updated = models.DateTimeField

Django South: Creating schemamigration for more than one app

女生的网名这么多〃 提交于 2019-12-05 08:54:15
问题 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 (using migrate --all). So I'd like to know if theres an easy solution for django south to handle a bunch of apps at once or if anyone has a nice script ready for

Programmatically check whether there are django south migrations that need to be deployed

一笑奈何 提交于 2019-12-05 08:20:44
My deployment strategy looks like this (using Fabric): create a new virtualenv deploy new code in new virtualenv show a maintenance page copy the current db to new db migrate new db point new code to new db symlink current virtualenv to new venv restart services remove maintenance page I want to iterate fast. Now, most of the code changes do not contain migrations. Also, the db is growing, so there is much overhead created by copying the database everytime I deploy a (mostly small) change. To avoid copying the database I want to check whether there are migrations that need to be deployed

Renaming auth_user breaks migrations on fresh setup

泄露秘密 提交于 2019-12-05 05:39:57
Following what seems like good advice , I migrated from Django's built-in auth.User to my own app.User by doing a migration that renames auth_user to app_user . So far so good, this works fine. The problem comes when I set up a new machine. In my settings.py I have AUTH_USER_MODEL = 'app.User' . Because of this, when I run syncdb , the auth_user table is not created, so when I migrate , that migration fails. The only way around this I've found is to modify AUTH_USER_MODEL to point to auth.User , run syncdb and migrations up until the rename migration, then change AUTH_USER_MODEL back, then run

How do I “unconvert” an app from South (Django)?

点点圈 提交于 2019-12-05 04:43:54
I changed a lot in my models.py , including deleting a lot of fields, and renaming a couple of classes. schemamigration --auto worked fine, but trying migrate threw a bunch of errors. All my code is currently in development so I don't mind too much losing the data. So I want South to "unconvert" or "unmanage" an app so I can rebuild all the tables with syncdb again. Or I could delete all migration list and do schemamigration --initial again. Chris Pratt Yes, just delete the migrations and run schemamigration --initial again. You should do that anyways as normal course before moving to