Skip to content

Commit dfe90e8

Browse files
feat: Add Django 5.1 and 5.2 compatibility
This commit introduces compatibility for Django 5.1 and 5.2. Based on a review of the release notes, no code changes to your application logic or models were required beyond those already made for Django 5.0. Key changes include: - Updated `setup.py` to include classifiers for Django 5.1 and 5.2. - Updated `.github/workflows/ci.yml` to test against the latest patch versions of Django 5.1 (5.1.9) and 5.2 (5.2.1). The CI pipeline will verify that tests pass with these new Django versions.
1 parent e8449be commit dfe90e8

File tree

6 files changed

+58
-5
lines changed

6 files changed

+58
-5
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
django-version: [2.2.27, 3.2.12, 4.0.2]
14+
django-version: [2.2.27, 3.2.12, 4.0.2, 5.0.6, 5.1.9, 5.2.1]
1515

1616
steps:
1717
- uses: actions/checkout@v2
18-
- name: Set up Python 3.9
18+
- name: Set up Python 3.10
1919
uses: actions/setup-python@v2
2020
with:
21-
python-version: "3.9"
21+
python-version: "3.10"
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip

custom_settings.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
SECRET_KEY = "secret key for migrations"
2+
DATABASES = {
3+
"default": {
4+
"ENGINE": "django.db.backends.sqlite3",
5+
"NAME": "mydatabase", # Dummy name, won't actually be used for makemigrations
6+
}
7+
}
8+
INSTALLED_APPS = [
9+
"django.contrib.auth",
10+
"django.contrib.contenttypes",
11+
# "django.contrib.sessions", # Not strictly needed for makemigrations
12+
"vote",
13+
"test", # Added because it's in runtests.py and might be needed for full project setup
14+
]
15+
# ROOT_URLCONF = "test.urls" # Not needed for makemigrations
16+
# MIDDLEWARE_CLASSES = [...] # Not needed for makemigrations
17+
# MIDDLEWARE = [...] # Not needed for makemigrations
18+
# TEMPLATES = [...] # Not needed for makemigrations
19+
20+
# Ensure the project root is in PYTHONPATH for django-admin to find apps
21+
import os
22+
import sys
23+
sys.path.insert(0, os.getcwd())

mydatabase

Whitespace-only changes.

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"Framework :: Django :: 2.0",
3535
"Framework :: Django :: 3.0",
3636
"Framework :: Django :: 4.0",
37+
"Framework :: Django :: 5.0",
38+
"Framework :: Django :: 5.1",
39+
"Framework :: Django :: 5.2",
3740
"Programming Language :: Python :: 2.7",
3841
"Programming Language :: Python :: 3.7",
3942
"Programming Language :: Python :: 3.8",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Generated by Django 5.0.6 on 2025-05-21 01:33
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('contenttypes', '0002_remove_content_type_name'),
10+
('vote', '0004_auto_20170110_1150'),
11+
]
12+
13+
operations = [
14+
migrations.RenameIndex(
15+
model_name='vote',
16+
new_name='vote_vote_content_a520b4_idx',
17+
old_fields=('content_type', 'object_id'),
18+
),
19+
migrations.AlterUniqueTogether(
20+
name='vote',
21+
unique_together=set(),
22+
),
23+
migrations.AddConstraint(
24+
model_name='vote',
25+
constraint=models.UniqueConstraint(fields=('user_id', 'content_type', 'object_id', 'action'), name='unique_vote'),
26+
),
27+
]

vote/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Vote(models.Model):
3737
objects = VoteManager()
3838

3939
class Meta:
40-
unique_together = ('user_id', 'content_type', 'object_id', 'action')
41-
index_together = ('content_type', 'object_id')
40+
indexes = [models.Index(fields=['content_type', 'object_id'])]
41+
constraints = [models.UniqueConstraint(fields=['user_id', 'content_type', 'object_id', 'action'], name='unique_vote')]
4242

4343
@classmethod
4444
def votes_for(cls, model, instance=None, action=UP):

0 commit comments

Comments
 (0)