django/django — pull request #2483 by charettes (2014-03-26 01:54:03+00:00)
Title: Fixed the PostGIS circular imports caused by 1506c71a95.

refs #12030.

Hopefully this will be the latest fix for #12030.

1. We can't access `connection` at `IntegerField` creation time (module import time) since the PostGIS backend defines models with `IntegerField` and it triggers a circular import. Thus we must delay access to `connection`, hence the cached property.
2. We can't simply append those validators to `self.validators` to avoid polluting migration with database backend specific validators. Hence the `range_validators` property. See ff874f363ce6556577f03909b15c71c051d5b617.
3. We want to make sure `range_validators` behave just like normal validators in regard to their aggregation logic in `run_validators` while keeping the code DRY. Hence the `extra_validators` kwarg of `Field.run_validators()`.