django-south

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

我的未来我决定 提交于 2019-11-27 06:11:32
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, orphaned table than the new table created for my new model. I'm familiar with South, but based on this post

reverse engineer mysql database to create django app

最后都变了- 提交于 2019-11-27 05:28:12
问题 I basically want to take an existing mysql database structure created and used by a php app (codeigniter framework) and reverse engineer it to a django app. is there some tool to do this? south migrations maybe? 回答1: Create a project, and point your settings @ your database Then run ./manage.py inspectdb This will print out a python models file for the DB you're pointing at You can output this to a file by doing something like ./manage.py inspectdb > models.py And then you can move the file

Backwards migration with Django South

大兔子大兔子 提交于 2019-11-27 04:55:51
问题 Ok, so this seems like a really silly thing to ask, and I'm sure I'm missing something somewhere. How do you perform a backwards migration using South on Django? So I've tweaked my models, created a migration with schemamigration , run the migration with migrate , and now I realise that's not quite what I wanted and I want it back the way before. Short of manually editing db tables and removing migration files, how should I go about rolling the migration back? I find references to backward

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

南笙酒味 提交于 2019-11-27 04:02:52
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.CharField(max_length=64, db_index=True) I've made the changes to my model (replace every primary_key=True by

Easiest way to rename a model using Django/South?

ぃ、小莉子 提交于 2019-11-27 02:33:35
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(Bar) To keep it simple, I'm just trying to change the name from Foo to Bar , but ignore the foo member in

-bash: ./manage.py: Permission denied

痞子三分冷 提交于 2019-11-27 00:06:12
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. 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. Bamara Coulibaly To give yourself execute permission for the file containing the script use the command: chmod u+rwx filename.py To give other users permission to read and execute but not alter the shell script use: chmod go+rx filename

No Such Column Error in Django App After South Migration

我的未来我决定 提交于 2019-11-27 00:02:26
问题 I've run into the same issue presented by the commenter here: Django South - table already exists There was no follow-up, so I thought I'd post a new question. I have a Django app whose migrations I manage with South. I added a field to my model then ran ./manage schemamigration my_app --auto which ran as expected. Running ./manage migrate my_app however, resulted in an error indicating that the table associated with the model I changed already exists. This led me to the above linked question

Migrating ManyToManyField to null true, blank true, isn't recognized

走远了吗. 提交于 2019-11-26 23:01:35
问题 I have made a model change from standard = models.ManyToManyField(Standard) to standard = models.ManyToManyField(Standard, blank=True, null=True) South schemamigration for this app doesn't recognize the change? Similar to this question, which is unanswered: South migrations and changes to many-to-may fields 回答1: That behavior is correct: null doesn't mean anything at the database level when used with a ManyToManyField . The declaration of a ManyToManyField causes the creation of an

Why don't my south migrations work?

梦想的初衷 提交于 2019-11-26 22:28:02
问题 First, I create my database. create database mydb; I add "south" to installed Apps. Then, I go to this tutorial: http://south.aeracode.org/docs/tutorial/part1.html The tutorial tells me to do this: $ py manage.py schemamigration wall --initial >>> Created 0001_initial.py. You can now apply this migration with: ./manage.py migrate wall Great, now I migrate. $ py manage.py migrate wall But it gives me this error... django.db.utils.DatabaseError: (1146, "Table 'fable.south_migrationhistory'

What's the recommended approach to resetting migration history using Django South?

為{幸葍}努か 提交于 2019-11-26 16:46:51
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 or "clearing" the history manually (e.g. clear the db table, remove migration files from the migrations director