django-south

How can I replace a CharField to ForeignKey using south in django?

喜夏-厌秋 提交于 2019-12-11 06:39:22
问题 My task model: class Tasks(models.Model): state = models.CharField(max_length = 150) I want to change the state field to ForeignKey like state = models.ForeignKey(States) Where States model would be: class States(model.Model): name = models.CharField(max_length = 150) BTW I am using Django non-rel with django mongodb. Is it easy to do using south?or is thr any other way to do it? 回答1: I will do it in six steps (migrations): First step a data_migration (south command): I create the States

Can the South (for Django) insert rows of data into database?

瘦欲@ 提交于 2019-12-11 05:53:02
问题 I want to create a table, and then a list of data that should be inserted into that table. Does South have the capability to do such a thing? If so, do you have any reference as to show me how this can be done? I want to be able to do this because at this point, it seems like the only way to have the 'exact' same data is to manually insert them into the database ourselves. I want some 'nice' automated way of inserting rows in a table. 回答1: You'd want to use fixtures. Create a fixtures

How to migrate models from a models package hierarchy and not from models.py with SOUTH in Django?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 05:25:17
问题 Hy! I have my models in a hierarchy below "models" package: models |-a.py |-b.py instead of having all my models into the models.py But when I run the migration command for South it doesn't find any of them: schemamigration my_app --auto In the meta class already exists the app_label='my_app' I use auto because the tables are already changed. 回答1: Have you imported all the models in __init__.py ? If you've done that, there's effectively no difference in how it works. 来源: https://stackoverflow

Accidentally deleted my django south migration directory

筅森魡賤 提交于 2019-12-11 03:15:20
问题 I accidentally deleted the South migrations directory for one of my Django apps. This directory was not under git. So now there are migrations in the database that are not present on the disk. Some pointers on how I can recover from this will be much appreciated. 回答1: Without the option of any type of backup or finding the files somewhere, what you're going to have to do is make initial migrations and then fake them. $ ./manage.py schemamigration app --initial $ ./manage.py migrate app --fake

Django Migrating to a new Database

跟風遠走 提交于 2019-12-11 02:44:39
问题 I just joined a project using Django, and am attempting to initialize my own development server. When I attempt to do so, the migration fails for one of my apps. A model for this app has a sorl.thumbnail.ImageField, to add a logo. When the migration is attempted, I get the following error message: FATAL ERROR - The following SQL query failed: ALTER TABLE "accounts_account" ADD CONSTRAINT "logo_id_refs_file_ptr_id_7c3d1997" FOREIGN KEY ("logo_id") REFERENCES "filer_image" ("file_ptr_id")

django.contrib.comments 'not synced' after adding it to installed_apps

牧云@^-^@ 提交于 2019-12-11 02:34:06
问题 I want to replace a home-made comment object by a proxy of django.contrib.comments.models.Comment. I modified my comments/models.py, added django.contrib.comments to my installed_apps and set COMMENTS_APPS to my comment app's name. When running python manage.py syncdb (I use South), I get 'django.contrib.comments' in the 'not synced' apps, so the corresponding tables are not created. How can I get the tables related to django.contrib.comments to be created? thanks Julien 回答1: Table creation

Change Django model column default using South

僤鯓⒐⒋嵵緔 提交于 2019-12-10 21:27:36
问题 I'm using South with a Postgresql DB for a Django project. There is a model field that I'd like to change the default value for going forward. I dont need previous records effected. Just new records. Do I need to do a migration for this, or just change the model? OLD FIELD DETAIL: background_style = models.CharField(max_length=1, choices=BACKGROUND_STYLE, default=BackgroundStyleCode.CENTERED) NEW FIELD DETAIL: background_style = models.CharField(max_length=1, choices=BACKGROUND_STYLE, default

Changing DateField to DateTimeField in Django

折月煮酒 提交于 2019-12-10 18:02:20
问题 In my current models file for my app I've got some publish date fields, start and end date. However I'd like to change them from DateFields to DateTimeFields. This will give the user a little more flexibility when setting a publish date, as they would like to specify a time. I'm using south to do the database migrations, will I have any problems when changing the field in the database? Or will need to remove it? Then add it as a DateTimeField? Once I've done that, will i be able to set a

Forward class declaration in Python

混江龙づ霸主 提交于 2019-12-10 14:44:33
问题 I have two classes in order: class A(models): ... class B(models): a = models.ManyToManyField(A) Now I have to change my model to one below: class A(models): b = models.ManyToManyField(B) class B(models): ... I have to use south migrations. I wanted to create new many to many field in class A, migrate data and delete field from class B. The problem is that both are in same model. So when I put many to many into A class it cannot be seen. Because B declaration is below A. How to solve this

Problems installing South with Django (south_migrationhistory tables do not get created)

你说的曾经没有我的故事 提交于 2019-12-10 14:22:06
问题 I cannot seem to get this working. I need South to do migrations for a bunch of apps. Downloaded south 0.7.3 Unzipped, ran setup.py develop (as it says in the turorial) Double checked to see if it south is where it should be by going to python interpreter and doing (no errors) import south I do C:\Users\j\iMiCode\imi_admin>python ./manage.py syncdb Syncing... No fixtures found. Synced: > django.contrib.auth > django.contrib.contenttypes > django.contrib.sessions > django.contrib.sites >