All good things come to an end. Version 4.2 is the new Django LTS-version (Long Term Support) for a popular Python web framework. This is how you can upgrade your project handily with django-upgrade.
Kalle Tolonen
May 17, 2023
Install it with pip straight away, or add it to your requirements.txt. Use a virtual environment to be safe and sane.
sudo apt-get install virtualenv
Start up the env.
source env/bin/activate
Install django-upgrade.
pip install django-upgrade
I prefer the requirements.txt-route:
requirements.txt
django===4.2.1
django-upgrade
pip install -r requirements.txt
Use the command:
django-upgrade --target-version 4.2.1 example/core/models.py example/settings.py
In my case, I needed to upgrade my urls.
django-upgrade --target-version 4.2.1 pathto/urls.py
Worked like a charm and fixed paths and static files on one go!
To verify the results, I checked that my setup worked and my dev-server was running great locally and then yolo-pushed the changes to my production server, since it's just this site and it has nothing that a database restore + git can't change back to way it was.
django-admin --version
Actually I had some worries regarding MarkdownX, so I had to mod it's paths a bit to comply with Django 4.2 syntax. Here's the updated urls.py of that plugin for anyone experiencing similar woes:
"""
**MarkdownX** default URLs, to be added to URLs in the main project.
See URLs in :doc:`../../example` to learn more.
"""
from django.urls import path
from .views import (
ImageUploadView,
MarkdownifyView,
)
urlpatterns = [
path('upload/', ImageUploadView.as_view(), name='markdownx_upload'),
path('markdownify/', MarkdownifyView.as_view(), name='markdownx_markdownify'),
]
No published comments yet.
Your comment may be published.