[PR #1333] [MERGED] Upgrade Django (Django-1.10 no longer supported) #2194

Closed
opened 2026-02-27 12:09:49 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/modoboa/modoboa/pull/1333
Author: @ghost
Created: 12/19/2017
Status: Merged
Merged: 12/21/2017
Merged by: @tonioo

Base: masterHead: upgrade-django


📝 Commits (10+)

  • e6befb3 standardise travis.yml across modoboa extensions
  • 3308c56 StopIterator has been depreciated, use return [PEP479]
  • 892160d updates for django 1.11 support
  • e8eb9a8 passlib 1.7 depreciated the use of .encrypt(), use .hash()
  • 0cd444b django-reversion >= 2.0.0 should be used with django >= 1.8
  • 2e18acb upgrade django-auth-ldap and fix depreciated warning
  • ba86196 upgrade dependencies with minor version updates
  • 8fb3e24 upgrade to django 1.11
  • 4fe51d6 random code clean ups
  • 33b37ec updated new deployment settings.py

📊 Changes

70 files changed (+300 additions, -241 deletions)

View changed files

📝 .travis.yml (+20 -13)
📝 ldap-requirements.txt (+1 -1)
📝 modoboa/admin/forms/account.py (+1 -3)
📝 modoboa/admin/forms/domain.py (+1 -1)
📝 modoboa/admin/handlers.py (+1 -1)
📝 modoboa/admin/migrations/0001_initial.py (+12 -12)
📝 modoboa/admin/models/alias.py (+7 -5)
📝 modoboa/admin/models/domain_alias.py (+2 -1)
📝 modoboa/admin/models/mailbox.py (+5 -4)
📝 modoboa/admin/models/mxrecord.py (+5 -5)
📝 modoboa/admin/templatetags/admin_tags.py (+1 -1)
📝 modoboa/admin/tests/test_account.py (+1 -1)
📝 modoboa/admin/tests/test_alias.py (+1 -1)
📝 modoboa/admin/tests/test_api.py (+1 -1)
📝 modoboa/admin/tests/test_domain.py (+1 -1)
📝 modoboa/admin/tests/test_domain_alias.py (+1 -1)
📝 modoboa/admin/tests/test_export.py (+1 -1)
📝 modoboa/admin/tests/test_import_.py (+1 -1)
📝 modoboa/admin/tests/test_mailbox_operations.py (+1 -1)
📝 modoboa/admin/tests/test_mx.py (+1 -1)

...and 50 more files

📄 Description

Django 1.10 is now no longer supported, this PR upgrades modoboa to Django 1.11 (the last version of Django to support Python 2). There's an associated PR for each of the extensions to upgrade them as well.

I've split this into several patches to make it easier to follow:

  • e6befb3: make all the travis.yml settings the same across modoboa projects. Adds testing against Python 3.5 and enables most Python warnings, the warnings don't affect the test results but they do give you a heads up about things that are depreciated or wrong.

  • 3308c56: PEP479 depreciated StopIterators, they should be replace with return.

  • 892160d: fixes to support Django 1.11 (and 2.0)

    • MIDDLEWARE_CLASSES is replaced by MIDDLEWARE

    • add MiddlewareMixin to modoboa middlewares

    • on_delete will become a required parameter for ForeignKey() set it to the current default CASCADE

    • on_delete will become a required parameter for OneToOneField() set it to the current default CASCADE

    • reverse and reverse_lazy have moved to django.urls

    • RadioChoiceInput widget has been removed, replace with HorizontalRadioSelect

  • e8eb9a8 0cd444b 2e18acb ba86196: upgrade dependencies and fix any errors/warnings.

  • 8fb3e24: upgrade Django, the minimum version is pinned to 1.11.8 as this is the latest version that I've done the upgrade with.

  • 4fe51d6: random code cleanups.

    • removed duplicate imports

    • whitespace fixes

    • removed unnecessary u"" prefixes

    • added missing r"" prefixes where required

    • added missing default values to DynamicForm() to prevent possible unassigned variable access

  • 33b37ec: updated settings.py for new deployments

    • updated Django documentation urls to point to the current version

    • renamed MIDDLEWARE_CLASSES to MIDDLEWARE, MIDDLEWARE_CLASSES is depreciated in Django >= 1.10

    • whitespace and #noqa fixes

  • 92963a0: updated test_project, synced with a fresh deployment using Django 1.11.8 and updated settings.py so the tests environment matches a fresh deployment.


There is one remaining warning for Django 2.0 support in urls.py (example):

RemovedInDjango20Warning: Specifying a namespace in django.conf.urls.include() without providing an app_name is deprecated. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

The simple fix from the description is to add app_name = "modoboa" to urls.py however this then requires every (and there's a lot of them) reverse("<url>") or reverse("<namespace>:<url>") to be prefixed with <app_name>. The documentation is very thin for this feature so I'm not sure what's the best solution, it's not a real issue until you upgrade to Django 2.0.


Extension PRs

When this is merged extensions will need their requirements.txt updated to point at this version as a minimum for modobo.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/modoboa/modoboa/pull/1333 **Author:** [@ghost](https://github.com/ghost) **Created:** 12/19/2017 **Status:** ✅ Merged **Merged:** 12/21/2017 **Merged by:** [@tonioo](https://github.com/tonioo) **Base:** `master` ← **Head:** `upgrade-django` --- ### 📝 Commits (10+) - [`e6befb3`](https://github.com/modoboa/modoboa/commit/e6befb3de92f6c65c9e496200014376d8c70bca3) standardise travis.yml across modoboa extensions - [`3308c56`](https://github.com/modoboa/modoboa/commit/3308c564807fbb069480238781caa89411e9031d) StopIterator has been depreciated, use return [PEP479] - [`892160d`](https://github.com/modoboa/modoboa/commit/892160d5aaa5c728c4dfef07db2293b739c38d3a) updates for django 1.11 support - [`e8eb9a8`](https://github.com/modoboa/modoboa/commit/e8eb9a84c1fc73a47ff596fd6b1e6eaab67a1980) passlib 1.7 depreciated the use of <hash>.encrypt(), use <hash>.hash() - [`0cd444b`](https://github.com/modoboa/modoboa/commit/0cd444be6b5dc6d42789fbaa4e9f89137d047f11) django-reversion >= 2.0.0 should be used with django >= 1.8 - [`2e18acb`](https://github.com/modoboa/modoboa/commit/2e18acb8ad251ddcf2f4b2a6afe975f5110df844) upgrade django-auth-ldap and fix depreciated warning - [`ba86196`](https://github.com/modoboa/modoboa/commit/ba861965b7d6d0bf48644993042c35ccb0102963) upgrade dependencies with minor version updates - [`8fb3e24`](https://github.com/modoboa/modoboa/commit/8fb3e244f63865741e1c30f53b39b757a92d15e4) upgrade to django 1.11 - [`4fe51d6`](https://github.com/modoboa/modoboa/commit/4fe51d6726d60d060a51051c65eada8bae1c5060) random code clean ups - [`33b37ec`](https://github.com/modoboa/modoboa/commit/33b37ec63e99169760c51e523f7e1969b18e9c4a) updated new deployment settings.py ### 📊 Changes **70 files changed** (+300 additions, -241 deletions) <details> <summary>View changed files</summary> 📝 `.travis.yml` (+20 -13) 📝 `ldap-requirements.txt` (+1 -1) 📝 `modoboa/admin/forms/account.py` (+1 -3) 📝 `modoboa/admin/forms/domain.py` (+1 -1) 📝 `modoboa/admin/handlers.py` (+1 -1) 📝 `modoboa/admin/migrations/0001_initial.py` (+12 -12) 📝 `modoboa/admin/models/alias.py` (+7 -5) 📝 `modoboa/admin/models/domain_alias.py` (+2 -1) 📝 `modoboa/admin/models/mailbox.py` (+5 -4) 📝 `modoboa/admin/models/mxrecord.py` (+5 -5) 📝 `modoboa/admin/templatetags/admin_tags.py` (+1 -1) 📝 `modoboa/admin/tests/test_account.py` (+1 -1) 📝 `modoboa/admin/tests/test_alias.py` (+1 -1) 📝 `modoboa/admin/tests/test_api.py` (+1 -1) 📝 `modoboa/admin/tests/test_domain.py` (+1 -1) 📝 `modoboa/admin/tests/test_domain_alias.py` (+1 -1) 📝 `modoboa/admin/tests/test_export.py` (+1 -1) 📝 `modoboa/admin/tests/test_import_.py` (+1 -1) 📝 `modoboa/admin/tests/test_mailbox_operations.py` (+1 -1) 📝 `modoboa/admin/tests/test_mx.py` (+1 -1) _...and 50 more files_ </details> ### 📄 Description Django 1.10 is now [no longer supported](https://www.djangoproject.com/download/#supported-versions), this PR upgrades modoboa to Django 1.11 (the last version of Django to support Python 2). There's an associated PR for each of the extensions to upgrade them as well. I've split this into several patches to make it easier to follow: - e6befb3: make all the travis.yml settings the same across modoboa projects. Adds testing against Python 3.5 and enables *most* Python warnings, the warnings don't affect the test results but they do give you a heads up about things that are depreciated or wrong. - 3308c56: [PEP479](https://www.python.org/dev/peps/pep-0479/#consequences-for-existing-code) depreciated StopIterators, they should be replace with return. - 892160d: fixes to support Django 1.11 (and 2.0) - MIDDLEWARE_CLASSES is replaced by MIDDLEWARE - add MiddlewareMixin to modoboa middlewares - on_delete will become a required parameter for ForeignKey() set it to the current default CASCADE - on_delete will become a required parameter for OneToOneField() set it to the current default CASCADE - reverse and reverse_lazy have moved to django.urls - RadioChoiceInput widget has been removed, replace with HorizontalRadioSelect - e8eb9a8 0cd444b 2e18acb ba86196: upgrade dependencies and fix any errors/warnings. - 8fb3e24: upgrade Django, the minimum version is pinned to 1.11.8 as this is the latest version that I've done the upgrade with. - 4fe51d6: random code cleanups. - removed duplicate imports - whitespace fixes - removed unnecessary u"" prefixes - added missing r"" prefixes where required - added missing default values to DynamicForm() to prevent possible unassigned variable access - 33b37ec: updated settings.py for new deployments - updated Django documentation urls to point to the current version - renamed MIDDLEWARE_CLASSES to MIDDLEWARE, MIDDLEWARE_CLASSES is depreciated in Django >= 1.10 - whitespace and #noqa fixes - 92963a0: updated test_project, synced with a fresh deployment using Django 1.11.8 and updated settings.py so the tests environment matches a fresh deployment. --- There is one remaining warning for **Django 2.0** support in urls.py ([example](https://github.com/modoboa/modoboa/blob/master/modoboa/urls.py#L28)): `RemovedInDjango20Warning: Specifying a namespace in django.conf.urls.include() without providing an app_name is deprecated. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.` The simple fix from the description is to add `app_name = "modoboa"` to urls.py however this then requires **every** (and there's a lot of them) `reverse("<url>")` or `reverse("<namespace>:<url>")` to be prefixed with `<app_name>`. The documentation is very thin for this feature so I'm not sure what's the best solution, it's not a real issue until you upgrade to Django 2.0. --- Extension PRs - modoboa/modoboa-amavis#81 - modoboa/modoboa-contacts#11 - modoboa/modoboa-dmarc#28 - modoboa/modoboa-imap-migration#29 - modoboa/modoboa-pdfcredentials#25 - modoboa/modoboa-postfix-autoreply#52 - modoboa/modoboa-radicale#17 - modoboa/modoboa-sievefilters#25 - modoboa/modoboa-stats#36 - modoboa/modoboa-webmail#136 **When this is merged extensions will need their requirements.txt updated to point at this version as a minimum for modobo.** --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 12:09:49 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#2194
No description provided.