django-south

Adding Simple Custom Field to Django — How to Write South Introspection Rules

我怕爱的太早我们不能终老 提交于 2019-12-04 06:48:01
I am trying to add a custom field to my Django project that uses South . Because of this, I am trying (for the first time) to write introspection rules for South . I believe my case is the simplest possible as I am simply extending a CharField. Specifically: class ColorField(models.CharField): def __init__(self, *args, **kwargs): kwargs['max_length'] = 10 super(ColorField, self).__init__(*args, **kwargs) def formfield(self, **kwargs): kwargs['widget'] = ColorPickerWidget return super(ColorField, self).formfield(**kwargs) This is from a Django snippet called jQuery color picker model field for

South migration for multi-table inheritance

你说的曾经没有我的故事 提交于 2019-12-04 06:11:54
I have a two models that previously inherited from models.Model and now I've refactored them to inherit from the same base model. Django is using multi-table inheritance for this and I'm trying to generate a schema and data migration for this. There is existing data in the database which needs to be migrated . I know that Django creates a OneToOneField, but I don't understand how it affects existing items in the database. Before Inheritance class BlogPost(models.Model): name = models.CharField() published_on = models.DateTimeField() class AudioFile(models.Model): file = models.FileField()

Consolidating Django South Migrations

旧巷老猫 提交于 2019-12-04 05:46:08
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? You could always delete the existing migrations and create a new "initial" migration . To do this, you will need to: Remove the migration files for you app (remove the folder altogether) Run ./manage.py convert_to_south myapp This

Default value of DateTimeField for South migration in Django project with activated timezone support

爷,独闯天下 提交于 2019-12-04 05:11:54
I'm creating a schema migration with South 0.7.6 for my Django 1.4.3 project with enabled timezone support. The schema migration includes adding a DateTimeField (with auto_now=True ) on one table. When creating the migration, South prompts me: The field 'MyTable.my_field' does not have a default specified, yet is NOT NULL. Since you are adding this field, you MUST specify a default value to use for existing rows. Would you like to: 1. Quit now, and add a default to the field in models.py 2. Specify a one-off value to use for existing columns now What's the correct one-off value to give here,

How to add one to one relation field in a existing model through South migration

不问归期 提交于 2019-12-04 05:08:58
I already have a model, class ModelA( models.Model ): name = models.CharField ( max_length = 255, blank = False ) and i have many entries in it. Now i want to add a field in it, which is user = models.OneToOneField( User ) How do i add this field into ModelA ? Is there any solution other than deleting all previous entries? I would use this pattern: Add "user = models.OneToOneField(User, null=True)" to your Model (don't remove the "name" field) run 'manage.py schemamigration --auto'. And apply the migration. Now there are two columns in your table. Now create a datamigration. Edit the file: you

Django Proxy Model Permissions Do Not Appear

为君一笑 提交于 2019-12-04 03:20:23
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.CharField(max_length=5) environment = models.CharField(max_length=8) is_scoped = models.BooleanField()

South: Unknown command 'migrate'

依然范特西╮ 提交于 2019-12-04 00:28:21
问题 I'm getting a merciless $ python manage.py migrate Unknown command: 'migrate' Type 'manage.py help' for usage. I pulled the code from github onto a fresh computer. This code is tested and is working on other computers. The entire code runs fine except for the fact I can't run migrations! Installed my virtual environment and ran pip install -r requirements.txt . It installs everything, including South. I can check by running $ python manage.py shell >>> import south >>> south.__version__ '0.7

South migrate error - relation already exists

只谈情不闲聊 提交于 2019-12-04 00:06:52
问题 Background: After adding djangoratings to my project, I tried running django-admin.py schemamigration djangoratings --initial --settings=myapp.settings.local which resulted in an unknown command error for schemamigration. I tried to resolve this error by adding my project directory to the PYTHONPATH (I'm using virtualenv and virtualenvwrapper). This resolved the unknown command error for schemamigration, but I think I specified one directory above my project directory for the PYTHONPATH and

Django south: changing field type in data migration

会有一股神秘感。 提交于 2019-12-03 23:28:49
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? 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 IntegerField And a final schema migration to remove the now unused CharField . A fourth one might be

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

别说谁变了你拦得住时间么 提交于 2019-12-03 22:27:35
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(auto_now=True) assignee = models.ForeignKey(User, null=True, related_name='assignee') reporter = models