#190 Upgrade from Python 2 to Python 3
Merged by bt0dotninja. Opened by shraddhaag.
fedora-commops/ shraddhaag/fedora-happiness-packets change-py2-to-py3  into  master

Download 190.patch

This commit upgrades FHP from Python 2 to Python 3 and Django 1.11
to Django 2.0.

The following changes have been done with the reasons listed below:

  1. Docker Image for python has been changed to Python3.6.8 [can't be upgraded to 3.7 due to this issue]
  2. Changed Django 1.11 to Django 2.0 [It can't be changed to 2.1 as django-haystack (used for search) doesn't support Django 2.1]
  3. Upgraded dependencies to work with Python 3 and Django 2.
  4. Changed all these deprecated instructions to recent instructions for Django 2.0:
    • django.core.urlresolvers => django.urls
    • url => re_path
    • app_name = 'messaging' is required for url namespacing in Django 2.0
    • render_to_response => render
    • MIDDLEWARE_CLASSES => MIDDLEWARE
    • configuring static files is changed to static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    • changed old style custom Middleware SetRemoteAddrFromForwardedFor using this
    • {% load static from staticfiles %}=> {% load static %}
  5. Django Debug Toolbar is configured to work only when Debug is set to true. It is disabled while testing as it causes this error
  6. Image is opened in binary mode ie rb to solve UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte.

Test suite is passed successfully after upgrading to Python3 and Django 2.1

Metadata Update from @jflory7:
- Pull-request tagged with: new change, type - backend, type - summer coding
- Request assigned

All looks good, none of the actual functionalities is broken I'm +1 for merge.

Pull-Request has been merged by bt0dotninja

@bt0dotninja Thank you so much for the speedy review :)