diff --git a/lms/djangoapps/coursewarehistoryextended/migrations/0001_initial.py b/lms/djangoapps/coursewarehistoryextended/migrations/0001_initial.py index 280d0f6d926a..8f788aefa607 100644 --- a/lms/djangoapps/coursewarehistoryextended/migrations/0001_initial.py +++ b/lms/djangoapps/coursewarehistoryextended/migrations/0001_initial.py @@ -44,7 +44,7 @@ class Migration(migrations.Migration): ('state', models.TextField(null=True, blank=True)), ('grade', models.FloatField(null=True, blank=True)), ('max_grade', models.FloatField(null=True, blank=True)), - ('id', models.BigAutoField(primary_key=True)), + ('id', models.BigAutoField(primary_key=True, serialize=False)), ('student_module', models.ForeignKey(to='courseware.StudentModule', on_delete=django.db.models.deletion.DO_NOTHING, db_constraint=False)), ], options={ diff --git a/openedx/core/djangoapps/common_initialization/apps.py b/openedx/core/djangoapps/common_initialization/apps.py index ccbe6d76d929..574a3f3b6154 100644 --- a/openedx/core/djangoapps/common_initialization/apps.py +++ b/openedx/core/djangoapps/common_initialization/apps.py @@ -4,6 +4,7 @@ from django.apps import AppConfig +from django.db import connection class CommonInitializationConfig(AppConfig): # lint-amnesty, pylint: disable=missing-class-docstring @@ -14,6 +15,7 @@ def ready(self): # Common settings validations for the LMS and CMS. from . import checks # lint-amnesty, pylint: disable=unused-import self._add_mimetypes() + self._add_required_adapters() @staticmethod def _add_mimetypes(): @@ -26,3 +28,17 @@ def _add_mimetypes(): mimetypes.add_type('application/x-font-opentype', '.otf') mimetypes.add_type('application/x-font-ttf', '.ttf') mimetypes.add_type('application/font-woff', '.woff') + + @staticmethod + def _add_required_adapters(): + if 'postgresql' in connection.vendor.lower(): + from opaque_keys.edx.locator import CourseLocator + from psycopg2.extensions import register_adapter, QuotedString + + + def adapt_course_locator(course_locator): + return QuotedString(course_locator._to_string()) + + + # Register the adapter + register_adapter(CourseLocator, adapt_course_locator)