Ticket #13206: django-model_init_super_r12847.patch

File django-model_init_super_r12847.patch, 1.3 KB (added by George Vilches, 15 years ago)

Enables support for Model.init super, against r12847.

  • django/db/models/base.py

     
    338338                    pass
    339339            if kwargs:
    340340                raise TypeError("'%s' is an invalid keyword argument for this function" % kwargs.keys()[0])
     341        super(Model, self).__init__()
    341342        signals.post_init.send(sender=self.__class__, instance=self)
    342343
    343344    def __repr__(self):
  • tests/modeltests/model_inheritance/models.py

     
    144144    def __unicode__(self):
    145145        return self.content
    146146
     147class MultiMixin(object):
     148    def __init__(self, *args, **kwargs):
     149        self.other_variable = 1
     150       
     151class MixinModel(models.Model, MultiMixin):
     152    pass
     153
    147154__test__ = {'API_TESTS':"""
    148155# The Student and Worker models both have 'name' and 'age' fields on them and
    149156# inherit the __unicode__() method, just as with normal Python subclassing.
     
    3763833
    377384>>> settings.DEBUG = False
    378385
     386>>> mm = MixinModel()
     387>>> getattr(mm, 'other_variable', False)
     3881
     389
    379390"""}
Back to Top