django-hstore
django-hstore copied to clipboard
Use signal and command to provide the same capability of the custom database backend
Current custom database backend does 3 things:
- Call register_hstore for each connection.
- Install hstore contrib for every database created.
- Create index for hstore field.
This commit use connection_created to do the first two things. And sqlhstoreindexes command to do the third thing.
Plus this commit also fixed an issue when using south to add an hstore field with a default value.
There are two reasons why I wanted to avoid using custom database backend:
- Other django app might monkey patch the database backend from django to provide some features. Use a custom backend might lose those features.
- If we have to write a custom backend when we add a new field type, next time when we add another field type we might have to write another backend. But in order to use those two field types simultaneously, we have to write a third backend to include both patches made by the first two. This don't sound very user friendly.
So I think it might be a good idea to provide the feature without using a custom backend.