All,
I have several custom fields on my models. I have tried adding "south_field_triple" methods on them in order to get db migration working. Initializing my application with south ("python manage.py convert_so_south myApp") works. But generating the first migration ("python manage.py schemamigration myApp --auto") fails with the following error:
TypeError: type() takes 1 or 3 arguments
The problem is occurring with the following field (I am not showing the code for the custom FormField or Widget; I assume those are not related to the cause of the problem):
class MyCustomField(models.CharField):
_type = "EnumerationField"
enumerationAppName = ""
enumerationModelName = ""
def __init__(self,*args,**kwargs):
enumeration = kwargs.pop('enumeration',None)
super(MyCustomField,self).__init__(*args,**kwargs)
if enumeration:
(self.enumerationAppName, self.enumerationModelName) = enumeration.split(".")
def getEnumeration(self):
try:
app = get_app(self.enumerationAppName)
enumeration = getattr(app,self.enumerationModelName)
return enumeration
except:
msg = "failed to get enumeration '%s.%s'" % (self.enumerationAppName,self.enumerationModelName)
print "error: %s" % msg
return None
def south_field_triple(self):
field_class_path = self.__class__.__module__ + "." + self.__class__.__name__
args,kwargs = introspector(self)
return (field_class_path,args,kwargs)
For what it's worth, this field presents the user with a set of choices. Those choices are defined in another class (specified by the "enumeration" argument to init). The FormField and Widget associated with this field use MultiValueField and MultiWidget, respectively, to present the user with a combo-box and a separate text box where the user can enter their own custom value not in the original enumeration. However, in the case of the model in the application being migrated - an enumeration is not provided.
Any ideas on what's gone wrong? Thanks.
edit: stacktrace added
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 459, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/site-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/south/management/commands/schemamigration.py", line 97, in handle
old_orm = last_migration.orm(),
File "/usr/local/lib/python2.7/site-packages/south/utils.py", line 62, in method
value = function(self)
File "/usr/local/lib/python2.7/site-packages/south/migration/base.py", line 422, in orm
return FakeORM(self.migration_class(), self.app_label())
File "/usr/local/lib/python2.7/site-packages/south/orm.py", line 46, in FakeORM
_orm_cache[args] = _FakeORM(*args)
File "/usr/local/lib/python2.7/site-packages/south/orm.py", line 126, in __init__
self.models[name] = self.make_model(app_label, model_name, data)
File "/usr/local/lib/python2.7/site-packages/south/orm.py", line 320, in make_model
field = self.eval_in_context(code, app, extra_imports)
File "/usr/local/lib/python2.7/site-packages/south/orm.py", line 238, in eval_in_context
return eval(code, globals(), fake_locals)
File "<string>", line 1, in <module>
TypeError: type() takes 1 or 3 arguments