mysociety/pombola — pull request #1432 by mhl (2014-05-22 19:00:38+00:00)
Title: Use the post_init signal instead of overriding the model contructor

Overwriting the constructor seemed to cause problems; in particular that
described in issue #1394:

Although under normal circumstances one can createPerson objects
and fetch them from the database fine with the new overriden
__init__, this fails if you call:

Person.objects.only('id', 'slug')

... as in core_list_malformed_slugs where the line:

if self.legal_name and not self.sort_name:

... causes the queryset to be evaluated again [which causes a
'RuntimeError: maximum recursion depth exceeded' error].

I've seen a suggestion in various places that overriding the
constructor of a Django model is a bad idea, and that one should use the
post_init signal instead. This commit makes that change, and adds a
test that fails with the previous code.

Fixes #1394.