Ticket #1142 (closed defect: invalid)

Opened 2 years ago

Last modified 2 years ago

__init__() takes at least 2 arguments (1 given) When Migrating using South with Custom Fields

Reported by: fady.kamal@… Owned by: andrew
Priority: major Milestone:
Component: migrations Version: 0.7.5
Keywords: Cc:


i am new to south and i followed their documentation and after initializing south migrations, after running migrate appname
for the following custom models Models i added introspection rules as follows


class DependentIntegerField?(models.IntegerField?):

def init(self, default_callable, *args, kwargs):

self.default_callable = default_callable
super(DependentIntegerField?, self).init(*args, kwargs)

def pre_save(self, model_instance, add):

if not add:

return super(DependentIntegerField?, self).pre_save(model_instance, add)

return self.default_callable(model_instance)

class Level(models.Model):

group = models.ForeignKey?(Level_Group)
number = models.IntegerField?(unique=True)#null=True, blank=True
threshold = DependentIntegerField?(lambda mi:mi.number*50,null=False,blank=True)

def str(self):

return '%s' %(self.number)

def get_fib(self):

return fib(self.number+3)

class Gallery (models.Model):

contractor = models.ForeignKey?(Contractor)
image = StdImageField?(upload_to='GalleryDB', size=(640, 480,True))
Title = models.CharField?(max_length=250,null=True,blank = True)
Caption = models.CharField?(max_length=1000,null=True,blank=True)

Introspection Rules :



[Level], # Class(es) these apply to
[], # Positional arguments (not used)
{ # Keyword argument

"threshold": ["threshold", {}],



], ^shoghlanah\.models\.DependentIntegerField?)



[Gallery], # Class(es) these apply to
[], # Positional arguments (not used)
{ # Keyword argument

"image": image?, "upload_to": GalleryDB?



], ^stdimage\.fields\.StdImageField?)

Traceback (most recent call last):

File "", line 10, in <module>


File "/Library/Python?/2.7/site-packages/django/core/management/", line 443, in execute_from_command_line


File "/Library/Python?/2.7/site-packages/django/core/management/", line 382, in execute


File "/Library/Python?/2.7/site-packages/django/core/management/", line 196, in run_from_argv

self.execute(*args, options.dict)

File "/Library/Python?/2.7/site-packages/django/core/management/", line 232, in execute

output = self.handle(*args, options)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/management/commands/", line 107, in handle

ignore_ghosts = ignore_ghosts,

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 219, in migrate_app

success = migrator.migrate_many(target, workplan, database)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 235, in migrate_many

result = migrator.class.migrate_many(migrator, target, migrations, database)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 310, in migrate_many

result = self.migrate(migration, database)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 133, in migrate

result =

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 99, in run

south.db.db.current_orm = self.orm(migration)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 260, in orm

return migration.orm()

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/utils/", line 62, in method

value = function(self)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/migration/", line 427, in orm

return FakeORM(self.migration_class(), self.app_label())

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/", line 45, in FakeORM

_orm_cache[args] = _FakeORM(*args)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/", line 124, in init

self.models[name] = self.make_model(app_label, model_name, data)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/", line 317, in make_model

field = self.eval_in_context(code, app, extra_imports)

File "/Library/Python?/2.7/site-packages/South-0.7.5-py2.7.egg/south/", line 235, 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)
i am little sure it's from the field DependentIntegerField? but i don't know which init is it trying to call and i tried

"threshold": ["threshold", {"ldefault_callable":default_callable}],
but i get

NameError?: name 'default_callable' is not defined


Change History

comment:1 Changed 2 years ago by andrew

  • Status changed from new to closed
  • Resolution set to invalid

Not a bug in South (there's a discussion about this on the mailing list already).


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.