Ticket #573 (assigned defect)
South fails to migrate on custom field AutoNow whcih extends Datetime field
| Reported by: | dextrous85@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.0 |
| Component: | migrations | Version: | unknown |
| Keywords: | Cc: |
Description
- Migrating forwards to 0001_initial.
milestones:0001_initial
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/init.py", line 362, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/init.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, options.dict)
File "/usr/local/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/base.py", line 222, in execute
output = self.handle(*args, options)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/management/commands/migrate.py", line 105, in handle
ignore_ghosts = ignore_ghosts,
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/init.py", line 191, in migrate_app
success = migrator.migrate_many(target, workplan, database)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/migrators.py", line 221, in migrate_many
result = migrator.class.migrate_many(migrator, target, migrations, database)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/migrators.py", line 292, in migrate_many
result = self.migrate(migration, database)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/migrators.py", line 125, in migrate
result = self.run(migration)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/migrators.py", line 93, in run
south.db.db.current_orm = self.orm(migration)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/migrators.py", line 246, in orm
return migration.orm()
File "/setup/trunk/sspl/src/ssplsite/../shared/south/utils.py", line 62, in method
value = function(self)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/migration/base.py", line 422, in orm
return FakeORM(self.migration_class(), self.app_label())
File "/setup/trunk/sspl/src/ssplsite/../shared/south/orm.py", line 46, in FakeORM
_orm_cache[args] = _FakeORM(*args)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/orm.py", line 125, in init
self.models[name] = self.make_model(app_label, model_name, data)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/orm.py", line 318, in make_model
field = self.eval_in_context(code, app, extra_imports)
File "/setup/trunk/sspl/src/ssplsite/../shared/south/orm.py", line 236, in eval_in_context
return eval(code, globals(), fake_locals)
File "<string>", line 1
SouthFieldClass?(default=datetime.datetime(2010, 8, 31, 4, 23, 35, 884429, tzinfo=<DstTzInfo? 'America/Chicago?' CDT-1 day, 19:00:00 DST>))
SyntaxError?: invalid syntax
Attachments
Change History
comment:1 Changed 3 years ago by andrew
- Priority changed from blocker to minor
- Status changed from new to assigned
- Milestone set to 0.7.3
Looks like the freezer is failing with timezones - I'll have to just modify it to ignore timezones.
In the meantime, you can work around it by manually editing the resulting migration.
comment:3 Changed 16 months ago by scytale@…
any other thoughts on how to work round this?
the exception is thrown before the migration is created so editing the migration is not an option.
I'd happily patch South - though I'm finding the code generation time-consuming to get my head around. Any hints on where the code to ignore timezones should go?
comment:4 Changed 13 months ago by anonymous
How is the exception thrown before migrating? I have the same problem and successfully solved it via sed:
python irrigation/manage.py schemamigration --auto rainman
find irrigation/rainman/migrations/ -name \*.py -mtime -0.1 -print0 | xargs -0r \
sed -i \
-e "s/{'default': 'datetime.datetime(.* tzinfo=<UTC>)'}/{}/" \
-e "s/'default': 'datetime.datetime(.* tzinfo=<UTC>)',//" \
-e "s/(default=datetime.datetime(.*tzinfo=<UTC>))/()/" \
-e "s/default=datetime.datetime(.*tzinfo=<UTC>),//"
python irrigation/manage.py migrate rainman
# might have to modify if broken
git add irrigation/rainman/migrations/*.py
Not my best sed script, in fact I should use perl instead (it has .*?), but ...
