base.py 1002 B

12345678910111213141516171819
  1. from django.db.backends.creation import NO_DB_ALIAS
  2. from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper as Psycopg2DatabaseWrapper
  3. from django.contrib.gis.db.backends.postgis.creation import PostGISCreation
  4. from django.contrib.gis.db.backends.postgis.introspection import PostGISIntrospection
  5. from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
  6. from django.contrib.gis.db.backends.postgis.schema import PostGISSchemaEditor
  7. class DatabaseWrapper(Psycopg2DatabaseWrapper):
  8. def __init__(self, *args, **kwargs):
  9. super(DatabaseWrapper, self).__init__(*args, **kwargs)
  10. if kwargs.get('alias', '') != NO_DB_ALIAS:
  11. self.creation = PostGISCreation(self)
  12. self.ops = PostGISOperations(self)
  13. self.introspection = PostGISIntrospection(self)
  14. def schema_editor(self, *args, **kwargs):
  15. "Returns a new instance of this backend's SchemaEditor"
  16. return PostGISSchemaEditor(self, *args, **kwargs)