Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.py 937B

1234567891011121314151617181920212223242526
  1. from django.db.backends.base.base import NO_DB_ALIAS
  2. from django.db.backends.postgresql.base import (
  3. DatabaseWrapper as Psycopg2DatabaseWrapper,
  4. )
  5. from .features import DatabaseFeatures
  6. from .introspection import PostGISIntrospection
  7. from .operations import PostGISOperations
  8. from .schema import PostGISSchemaEditor
  9. class DatabaseWrapper(Psycopg2DatabaseWrapper):
  10. SchemaEditorClass = PostGISSchemaEditor
  11. def __init__(self, *args, **kwargs):
  12. super().__init__(*args, **kwargs)
  13. if kwargs.get('alias', '') != NO_DB_ALIAS:
  14. self.features = DatabaseFeatures(self)
  15. self.ops = PostGISOperations(self)
  16. self.introspection = PostGISIntrospection(self)
  17. def prepare_database(self):
  18. super().prepare_database()
  19. # Check that postgis extension is installed.
  20. with self.cursor() as cursor:
  21. cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis")