Я использую настраиваемое поле модели Django и виджет для отображения виджета GoogleMap в моем администраторе, я также хочу использовать Юг с моим проектом для обработки миграций базы данных.Однако после долгих усилий я не могу сгенерировать настраиваемое южное правило, которое подходит, это моя пользовательская модель и последнее из многих правил интроспекции, которые я пробовал.
class GoogleMapMarkerField(models.CharField):
__metaclass__ = models.SubfieldBase
description = _('Un marcador de Google Maps')
widget = GoogleMapMarkerWidget
def __init__(self, center, *args, **kwargs):
kwargs['max_length'] = 100
kwargs['help_text'] = _('Arrastre el cursor en el mapa para seleccionar el punto')
self.center = center
super(GoogleMapMarkerField, self).__init__(*args, **kwargs)
def formfield(self, **kwargs):
defaults = {
'center': self.center,
'form_class':GoogleMapMarkerFormField
}
defaults.update(kwargs)
return super(GoogleMapMarkerField, self).formfield(**defaults)
def to_python(self, value):
if isinstance(value, GoogleMapMarker):
return value
if isinstance(value, list):
return GoogleMapMarker(*map(float, value))
elif isinstance(value, basestring):
try:
return GoogleMapMarker(*map(float, value.split(',')))
except ValueError:
pass
def get_prep_value(self, value):
return '%f,%f' % (value.latitude, value.longitude)
add_introspection_rules([
(
(GoogleMapMarkerField, ),
[],
{
'center': ('center', {}),
}
)
], ["^website\.fields\.GoogleMapMarkerField"])
И это обратная связь, котораяя получаю
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/management/commands/schemamigration.py", line 97, in handle
old_orm = last_migration.orm(),
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/utils.py", line 62, in method
value = function(self)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/migration/base.py", line 422, in orm
return FakeORM(self.migration_class(), self.app_label())
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 46, in FakeORM
_orm_cache[args] = _FakeORM(*args)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 125, in __init__
self.models[name] = self.make_model(app_label, model_name, data)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 321, in make_model
field = self.eval_in_context(code, app, extra_imports)
File "/home/armonge/workspace/env/lib/python2.7/site-packages/south/orm.py", line 236, in eval_in_context
return eval(code, globals(), fake_locals)
File "<string>", line 1, in <module>
TypeError: __init__() takes at least 2 arguments (1 given)