From ca9cfb128c2a140fdf6a40a2ec0563e87768ec0f Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Tue, 3 Sep 2019 09:08:17 -0400 Subject: [PATCH] Fix errors when running runserver in python 3. - The fields need to be unicode not bytes. In python 2 it was auto converting. - The static url base has been allowed to be a unicode string for a while. --- cms/envs/production.py | 3 +-- .../student/migrations/0022_indexing_in_courseenrollment.py | 2 +- lms/envs/production.py | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cms/envs/production.py b/cms/envs/production.py index f9702ea18a..a2fdc17297 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -116,8 +116,7 @@ EDX_PLATFORM_REVISION = ENV_TOKENS.get('EDX_PLATFORM_REVISION', EDX_PLATFORM_REV # STATIC_URL_BASE specifies the base url to use for static files STATIC_URL_BASE = ENV_TOKENS.get('STATIC_URL_BASE', None) if STATIC_URL_BASE: - # collectstatic will fail if STATIC_URL is a unicode string - STATIC_URL = STATIC_URL_BASE.encode('ascii') + STATIC_URL = STATIC_URL_BASE if not STATIC_URL.endswith("/"): STATIC_URL += "/" STATIC_URL += 'studio/' diff --git a/common/djangoapps/student/migrations/0022_indexing_in_courseenrollment.py b/common/djangoapps/student/migrations/0022_indexing_in_courseenrollment.py index 8b313ff544..c4a9065ef2 100644 --- a/common/djangoapps/student/migrations/0022_indexing_in_courseenrollment.py +++ b/common/djangoapps/student/migrations/0022_indexing_in_courseenrollment.py @@ -14,6 +14,6 @@ class Migration(migrations.Migration): operations = [ migrations.AddIndex( model_name='courseenrollment', - index=models.Index(fields=[b'user', b'-created'], name='student_cou_user_id_b19dcd_idx'), + index=models.Index(fields=['user', '-created'], name='student_cou_user_id_b19dcd_idx'), ), ] diff --git a/lms/envs/production.py b/lms/envs/production.py index fc6196672a..d71789ef53 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -137,8 +137,7 @@ if STATIC_ROOT_BASE: # STATIC_URL_BASE specifies the base url to use for static files STATIC_URL_BASE = ENV_TOKENS.get('STATIC_URL_BASE', None) if STATIC_URL_BASE: - # collectstatic will fail if STATIC_URL is a unicode string - STATIC_URL = STATIC_URL_BASE.encode('ascii') + STATIC_URL = STATIC_URL_BASE if not STATIC_URL.endswith("/"): STATIC_URL += "/"