django-south

Deploying a (single node) Django Web application with virtually zero downtime on EC2

给你一囗甜甜゛ 提交于 2019-12-10 12:48:38
问题 Question: What are good strategies for achieving 0 (or as close as possible to 0) downtime when using Django? Most of the answer I read say "use south" or "use fabric", but those are very vague answer IMHO. I actually use both, and am still wondering how to achieve zero downtime as much as possible. Some details: I have a decently sized Django application that I host at EC2. I use South for schema and data migrations as well as fabric with boto for automating repetitive deployment/backup

django south migration and USE_TZ=True

爱⌒轻易说出口 提交于 2019-12-10 11:40:36
问题 I've changed all my code to use aware-time by using django.utils.timezone.now() I changed datetimefield to use default=timezone.now , and set USE_TZ=True in settings.py After the changes, I ran south schemamigration command and it doesn't pick up the database fields change. I'm using the south 0.7.6 and postgresql if that matters. Here's the detailed change I made to make my entire site timezone aware. how do I make my site timezone aware? 回答1: If you use south, and change USE_TZ=False to USE

Can't add a new field in migration: “column .. does not exist”

醉酒当歌 提交于 2019-12-10 10:05:46
问题 I want to add a field to my model but I'm completely lost here. This is the model, the app name is called "profiles": class Profiles(models.Model): user = models.OneToOneField(User, unique=True, null=True) nickname = models.CharField(max_length=75, null=True) # new field description = models.CharField(max_length=250, blank=True, null=True) So, I added the "nickname" field. Then I ran python manage.py schemamigration profiles --auto python manage.py migrate profiles But it gave me an error.

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

眉间皱痕 提交于 2019-12-09 18:05:16
问题 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.

Is there a Django 1.7+ replacement for South's add_introspection_rules()?

倾然丶 夕夏残阳落幕 提交于 2019-12-09 08:08:33
问题 Back in the days of South migrations, if you wanted to create a custom model field that extended a Django field's functionality, you could tell South to use the introspection rules of the parent class like so: from south.modelsinspector import add_introspection_rules add_introspection_rules([], ["^myapp\.stuff\.fields\.SomeNewField"]) Now that migrations have been moved to Django, is there a non-South equivalent of the above? Is an equivalent even needed anymore, or is the new migration stuff

django south migration, doesnt set default

三世轮回 提交于 2019-12-09 05:40:54
问题 I use south to migrate my django models. There is however a nasty bug in south. It doesn't set default values in Postgres Databases. Example: created_at = models.DateTimeField(default = datetime.now) tag_id = models.PositiveIntegerField(default = 0) South will add these 2 fields to database, but fail to set their default values, which needs to be done manually. Is there any patch for this bug? UPDATE I had already tried setting default date with auto_now_add=True , but that is also not

In Django/South HOWTO create an instance of a model from a different app during DataMigration

陌路散爱 提交于 2019-12-08 19:51:17
问题 I need to perform a datamigration of a model Answer in app Question . In that script there is a dependency such that I need to create an instance of a model Chapter which is in the app Journal . So, I coded it as follows: def forwards(self, orm): for answer_object in orm.Answer.objects.all(): #This Works. blog, is_created = orm['blog.Post'].objects.get_or_create(title=answer_object.answer[:100]) blog.save() #This DOES NOT work chapter, is_created = orm['journal.Chapter'].objects.get_or_create

What migration order does South follow across different apps?

流过昼夜 提交于 2019-12-08 17:09:36
问题 I've recently begun using South for migrations in my Django project. All was going well until recently when I ran into a peculiar issue. I have two apps in my project, say, App-A and App-B. A model in App-A has a foreign key to a model in App-B. When I've been trying to build my system, I ran syndb which created all the auth_ and the south_ tables. Then I ran migrate which threw up errors. When it tried creating the model from App-A, which referenced a model from App-B, the model App-B wasn't

South ignores change in field default value in Python / Django

瘦欲@ 提交于 2019-12-08 15:13:24
问题 Why does South not recognize changes in default field values in Python models? For example, take this existing model that is migrated with south: class MyFamily(models.Model): family_size = models.IntegerField(verbose_name="What is your family size?", default=2) Now, I'd like to change the default value from two to four. However, when schemamigrating the module, South reports: python manage.py schemamigration family --auto change_default_from_two_to_four_for_size Running migrations for family

How do I access auth User's User.objects.create_user(…) in a south migration?

匆匆过客 提交于 2019-12-08 14:56:11
问题 Instead of using django's auth module I've used my own and already regret it a lot. In an effort to rectify the situation, I'm trying to migrate the data from my User model to django.auth.models.User. I've created a data migration as follows: def forwards(self, orm): """Migrate user information from mooi User model to auth User model.""" OldUser = orm['mooi.User'] User = orm['auth.User'] Profile = orm['mooi.Profile'] oldUsers = OldUser.objects.all() for oldUser in oldUsers: newUser = User