Skip to content

Commit 4ad8f12

Browse files
Support testing with Django 5.1.
1 parent c86ce01 commit 4ad8f12

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/models.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import django
12
from django.db import models
23

34
from postgres_copy import CopyManager, CopyMapping
@@ -17,7 +18,13 @@ class MockObject(models.Model):
1718
class Meta:
1819
app_label = "tests"
1920
unique_together = ("name", "number")
20-
index_together = ("name", "number")
21+
22+
def __init__(self, *args, **kwargs):
23+
super().__init__(*args, **kwargs)
24+
if django.get_version() <= '5.1':
25+
self._meta.index_together = ("name", "number")
26+
else:
27+
self._meta.indexes = [models.Index(fields=["name", "number"])]
2128

2229
def copy_name_template(self):
2330
return 'upper("%(name)s")'

0 commit comments

Comments
 (0)