django-south

Django South - table already exists

一笑奈何 提交于 2019-11-26 14:58:18
问题 I am trying to get started with South. I had an existing database and I added South ( syncdb , schemamigration --initial ). Then, I updated models.py to add a field and ran ./manage.py schemamigration myapp --auto . It seemed to find the field and said I could apply this with ./manage.py migrate myapp . But, doing that gave the error: django.db.utils.DatabaseError: table "myapp_tablename" already exists tablename is the first table listed in models.py . I am running Django 1.2, South 0.7 回答1:

Django - How to rename a model field using South?

…衆ロ難τιáo~ 提交于 2019-11-26 12:34:53
问题 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? 回答1: You can use the db.rename_column function. class Migration: def forwards(self, orm): # Rename 'name' field to 'full_name' db.rename_column('app_foo', 'name', 'full_name') def backwards(self,

Easiest way to rename a model using Django/South?

旧巷老猫 提交于 2019-11-26 12:34:20
问题 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 = models.CharField() foo = models.ForeignKey(Foo) and you want to convert Foo to Bar, namely class Bar(models.Model): name = models.CharField() class FooTwo(models.Model): name = models.CharField() foo = models.ForeignKey

-bash: ./manage.py: Permission denied

对着背影说爱祢 提交于 2019-11-26 12:22:00
问题 After running: $ ./manage.py migrate I am getting the following error: -bash: ./manage.py: Permission denied Trying to run a migration after making a change in the DB. Any advice would be really appreciated. 回答1: You need to make manage.py executable to excecute it. Do chmod +x manage.py to make it excecutable. Alternately you can do python manage.py <cmd> instead. 回答2: To give yourself execute permission for the file containing the script use the command: chmod u+rwx filename.py To give

Migrating existing auth.User data to new Django 1.5 custom user model?

喜你入骨 提交于 2019-11-26 11:56:08
问题 I\'d prefer not to destroy all the users on my site. But I want to take advantage of Django 1.5\'s custom pluggable user model. Here\'s my new user model: class SiteUser(AbstractUser): site = models.ForeignKey(Site, null=True) Everything works with my new model on a new install (I\'ve got other code, along with a good reason for doing this--all of which are irrelevant here). But if I put this on my live site and syncdb & migrate, I\'ll lose all my users or at least they\'ll be in a different,

How do I migrate a model out of one django app and into a new one?

两盒软妹~` 提交于 2019-11-26 06:12:36
问题 I have a django app with four models in it. I realize now that one of these models should be in a separate app. I do have south installed for migrations, but I don\'t think this is something it can handle automatically. How can I migrate one of the models out of the old app into a new one? Also, keep in mind that I\'m going to need this to be a repeatable process, so that I can migrate the production system and such. 回答1: How to migrate using south. Lets say we got two apps: common and

What&#39;s the recommended approach to resetting migration history using Django South?

与世无争的帅哥 提交于 2019-11-26 04:56:41
问题 I\'ve accumulated quite a few migrations using South (0.7) and Django (1.1.2) which are starting to consume quite a bit of time in my unit tests. I would like to reset the baseline and start a fresh set of migrations. I\'ve reviewed the South documentation, done the usual Google/Stackoverflow searching (e.g. \"django south (reset OR delete OR remove) migration history\") and haven\'t found anything obvious. One approach I\'ve contemplated would involve \"starting over\" by \"removing\" South