Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-django-mptt for 
openSUSE:Factory checked in at 2026-04-07 16:33:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-mptt (Old)
 and      /work/SRC/openSUSE:Factory/.python-django-mptt.new.21863 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-django-mptt"

Tue Apr  7 16:33:43 2026 rev:5 rq:1344814 version:0.18

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-django-mptt/python-django-mptt.changes    
2025-04-23 15:19:18.030020279 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-django-mptt.new.21863/python-django-mptt.changes
 2026-04-07 16:49:24.069761429 +0200
@@ -1,0 +2,6 @@
+Mon Mar 30 21:50:06 UTC 2026 - Dirk Müller <[email protected]>
+
+- update to 0.18:
+  * Fixed the way indexes are defined for Django 5 and better.
+
+-------------------------------------------------------------------

Old:
----
  0.17.tar.gz

New:
----
  0.18.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-django-mptt.spec ++++++
--- /var/tmp/diff_new_pack.yqRHhG/_old  2026-04-07 16:49:24.533780617 +0200
+++ /var/tmp/diff_new_pack.yqRHhG/_new  2026-04-07 16:49:24.537780783 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-django-mptt
 #
-# Copyright (c) 2025 SUSE LLC
+# Copyright (c) 2026 SUSE LLC and contributors
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?sle15_python_module_pythons}
 Name:           python-django-mptt
-Version:        0.17
+Version:        0.18
 Release:        0
 Summary:        Modified Preorder Tree Traversal for Django Models
 License:        MIT
@@ -44,8 +44,6 @@
 
 %prep
 %setup -q -n django-mptt-%{version}
-sed -i 's/from model_mommy import mommy/from model_bakery import baker as 
mommy/' tests/myapp/tests.py
-sed -i 's/test_create_by_mommy_exception/_test_create_by_mommy_exception/' 
tests/myapp/tests.py
 
 %build
 %pyproject_wheel
@@ -62,5 +60,5 @@
 %doc README.rst
 %license LICENSE
 %{python_sitelib}/mptt/
-%{python_sitelib}/django[-_]mptt*/
+%{python_sitelib}/django[-_]mptt-%{version}.0.dist-info
 

++++++ 0.17.tar.gz -> 0.18.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-mptt-0.17/CHANGELOG.rst 
new/django-mptt-0.18/CHANGELOG.rst
--- old/django-mptt-0.17/CHANGELOG.rst  2025-04-04 10:30:27.000000000 +0200
+++ new/django-mptt-0.18/CHANGELOG.rst  2025-08-26 11:26:51.000000000 +0200
@@ -5,6 +5,11 @@
 Next version
 ============
 
+0.18
+====
+
+- Fixed the way indexes are defined for Django 5 and better.
+
 0.17
 ====
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-mptt-0.17/docs/admin.rst 
new/django-mptt-0.18/docs/admin.rst
--- old/django-mptt-0.17/docs/admin.rst 2025-04-04 10:30:27.000000000 +0200
+++ new/django-mptt-0.18/docs/admin.rst 2025-08-26 11:26:51.000000000 +0200
@@ -189,5 +189,5 @@
 
     # ...
     class MyTreeRelatedFieldListFilter(TreeRelatedFieldListFilter):
-    mptt_level_indent = 20
+        mptt_level_indent = 20
     # ...
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-mptt-0.17/mptt/__init__.py 
new/django-mptt-0.18/mptt/__init__.py
--- old/django-mptt-0.17/mptt/__init__.py       2025-04-04 10:30:27.000000000 
+0200
+++ new/django-mptt-0.18/mptt/__init__.py       2025-08-26 11:26:51.000000000 
+0200
@@ -1,4 +1,4 @@
-__version__ = "0.17.0"
+__version__ = "0.18.0"
 
 
 def register(*args, **kwargs):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-mptt-0.17/mptt/models.py 
new/django-mptt-0.18/mptt/models.py
--- old/django-mptt-0.17/mptt/models.py 2025-04-04 10:30:27.000000000 +0200
+++ new/django-mptt-0.18/mptt/models.py 2025-08-26 11:26:51.000000000 +0200
@@ -4,9 +4,9 @@
 import threading
 from functools import reduce, wraps
 
-import django
 from django.conf import settings
 from django.db import models
+from django.db.backends.utils import truncate_name
 from django.db.models.base import ModelBase
 from django.db.models.query import Q
 from django.db.models.query_utils import DeferredAttribute
@@ -373,16 +373,24 @@
                         )
                         field.contribute_to_class(cls, field_name)
 
-                if django.VERSION < (5,):
-                    # Add an index_together on tree_id_attr and left_attr, as 
these are very
-                    # commonly queried (pretty much all reads).
-                    # Django 5.0 (or 5.1?) only accepts Meta.indexes
-                    index_together = (
-                        cls._mptt_meta.tree_id_attr,
-                        cls._mptt_meta.left_attr,
+                index_fields = (
+                    cls._mptt_meta.tree_id_attr,
+                    cls._mptt_meta.left_attr,
+                )
+                for index in cls._meta.indexes:
+                    if tuple(index.fields) == index_fields:
+                        break
+                else:
+                    cls._meta.indexes.append(
+                        models.Index(
+                            fields=index_fields,
+                            name=truncate_name(
+                                
f"{cls._meta.app_label}_{cls._meta.model_name}_"
+                                
f"{cls._mptt_meta.tree_id_attr}_{cls._mptt_meta.left_attr}_idx",
+                                models.Index.max_name_length,
+                            ),
+                        )
                     )
-                    if index_together not in cls._meta.index_together:
-                        cls._meta.index_together += (index_together,)
 
             # Add a tree manager, if there isn't one already
             if not abstract:
@@ -401,15 +409,6 @@
                                 tree_manager = cls_manager
                                 break
 
-                if is_cls_tree_model and django.VERSION < (5,):
-                    idx_together = (
-                        cls._mptt_meta.tree_id_attr,
-                        cls._mptt_meta.left_attr,
-                    )
-
-                    if idx_together not in cls._meta.index_together:
-                        cls._meta.index_together += (idx_together,)
-
                 if tree_manager and tree_manager.model is not cls:
                     tree_manager = tree_manager._copy_to_model(cls)
                 elif tree_manager is None:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-mptt-0.17/tests/myapp/tests.py 
new/django-mptt-0.18/tests/myapp/tests.py
--- old/django-mptt-0.17/tests/myapp/tests.py   2025-04-04 10:30:27.000000000 
+0200
+++ new/django-mptt-0.18/tests/myapp/tests.py   2025-08-26 11:26:51.000000000 
+0200
@@ -9,7 +9,7 @@
 from django.contrib.admin import ModelAdmin, site
 from django.contrib.admin.views.main import ChangeList
 from django.contrib.auth.models import Group, User
-from django.db.models import Q
+from django.db.models import Index, Q
 from django.db.models.query_utils import DeferredAttribute
 from django.template import Context, Template, TemplateSyntaxError
 from django.test import RequestFactory, TestCase, override_settings
@@ -2989,16 +2989,24 @@
             field_name = getattr(SomeModel._mptt_meta, key)
             self.assertFalse(SomeModel._meta.get_field(field_name).db_index)
 
-    @unittest.skipUnless(django.VERSION < (5,), "Django 5 only accepts 
Meta.indexes")
-    def test_index_together(self):
-        already_idx = [["tree_id", "lft"], ("tree_id", "lft")]
+    @staticmethod
+    def index_fields(model):
+        return (tuple(index.fields) for index in model._meta.indexes)
+
+    def test_indexes(self):
+        already_idx = [
+            [
+                Index(fields=["tree_id", "lft"], name="original_idx"),
+                Index(fields=["tree_id", "lft"], name="duplicate_idx"),
+            ],
+        ]
         no_idx = [(), []]
-        some_idx = [["tree_id"], ("tree_id",), [["tree_id"]], (("tree_id",),)]
+        some_idx = [[Index(fields=["tree_id"], name="test_some_idx")]]
 
         for idx, case in enumerate(already_idx + no_idx + some_idx):
 
             class Meta:
-                index_together = case
+                indexes = case
                 app_label = "myapp"
 
             # Use type() here and in test_index_together_different_attr over
@@ -3016,13 +3024,17 @@
                 },
             )
 
-            self.assertIn(("tree_id", "lft"), SomeModel._meta.index_together)
+            self.assertIn(("tree_id", "lft"), self.index_fields(SomeModel))
 
-    @unittest.skipUnless(django.VERSION < (5,), "Django 5 only accepts 
Meta.indexes")
     def test_index_together_different_attr(self):
-        already_idx = [["abc", "def"], ("abc", "def")]
+        already_idx = [
+            [
+                Index(fields=["abc", "def"], name="original_idx"),
+                Index(fields=("abc", "def"), name="duplicate_idx"),
+            ]
+        ]
         no_idx = [(), []]
-        some_idx = [["abc"], ("abc",), [["abc"]], (("abc",),)]
+        some_idx = [[Index(fields=["abc"], name="some_idx")]]
 
         for idx, case in enumerate(already_idx + no_idx + some_idx):
 
@@ -3031,7 +3043,7 @@
                 left_attr = "def"
 
             class Meta:
-                index_together = case
+                indexes = case
                 app_label = "myapp"
 
             SomeModel = type(
@@ -3040,7 +3052,7 @@
                 {"MPTTMeta": MPTTMeta, "Meta": Meta, "__module__": 
str(__name__)},
             )
 
-            self.assertIn(("abc", "def"), SomeModel._meta.index_together)
+            self.assertIn(("abc", "def"), self.index_fields(SomeModel))
 
 
 class BulkLoadTests(TestCase):

Reply via email to