views:

46

answers:

1

I'm trying to debug a Python Django app.

I've got additional fields being added to a model.

I've tracked this down to one method:
django.db.models.options.add_field()

The only place this method is called is:
django.db.models.fields.init.contribute_to_class()

def contribute_to_class(self, cls, name):
  self.set_attributes_from_name(name)
  cls._meta.add_field(self)
  if self.choices:
    setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self))

I'm trying to use Logging to determine where the additions to the User model are occurring.

Is there anyway to that I can set a logging message that will record where this contribute_to_class() method was called from?

+1  A: 

Use traceback module.

gruszczy