Skip to content

Conversation

@thiago4455
Copy link

@thiago4455 thiago4455 commented Nov 2, 2024

Big code refactoring to update dependencies. #160
This work was motivated by the difficulties of setting up Python 2.7 and Django 1.9 apps on modern environments. Mainly due to trusted repositories not shipping old versions, and modern versions occupying the expected installation paths and binary names.

Overview of the changes made:

  • Changed Docker base image to python:3, and installing dependencies directly from requirements.txt
  • Grappelli version upper bound was removed, and django-solo-grappelli was replaced by the up to date django-solo.
  • django-loginas was removed due to not being compatible with recent python versions, and I couldn't see the value of this functionality. If required we can replace it with modern solutions for this same feature.
  • python3 changed how it handles loading modules on the current directory, so a . was prepended whenever was required.
  • In newer versions of Django, the on_delete argument is required for ForeignKey fields. For all instances it was used on_delete=models.CASCADE, to comply with the previous behaviour.
  • print statements where updated accordingly
  • __unicode__ replaced with __str__
  • all map functions were wrapped with list, so that it complies with the expected behaviour from python2.
  • {% load staticfiles %} replaced by {% load static %}
  • Old Django url calls replaced with re_path.
  • MiddlewareMixin added on URLLocaleMiddleware to replicate how previous Django versions called middlewares
  • MIDDLEWARE_CLASSES replaced with MIDDLEWARE on settings.py
  • DEFAULT_AUTO_FIELD='django.db.models.AutoField' used to replicate the old default type for primary keys

A manual sqlite command was run to remove non corresponding foreign keys
that was causing migration error:

UPDATE IPT2018_team SET IOC_id = NULL;

Thiago Mattos added 5 commits November 2, 2024 15:33
A manual sqlite command was run to remove non corresponding foreign keys
that was causing migration error:
UPDATE IPT2018_team SET IOC_id = NULL;

Then migrations were applied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant