public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-django-extensions] rawhide: Backport fix for Django 6 support regressions; Fixes rhbz#2458683
@ 2026-06-16 17:15 Michel Lind
  0 siblings, 0 replies; only message in thread
From: Michel Lind @ 2026-06-16 17:15 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/python-django-extensions
            Branch : rawhide
            Commit : 4b4327800747df9816a94c0b383b24d1afe54dc7
            Author : Michel Lind <salimma@fedoraproject.org>
            Date   : 2026-06-16T17:56:01+01:00
            Stats  : +101/-3 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-django-extensions/c/4b4327800747df9816a94c0b383b24d1afe54dc7?branch=rawhide

            Log:
            Backport fix for Django 6 support regressions; Fixes rhbz#2458683

Signed-off-by: Michel Lind <salimma@fedoraproject.org>

---
diff --git a/django-extensions-fix-django6-regressions.diff b/django-extensions-fix-django6-regressions.diff
new file mode 100644
index 0000000..68f3c03
--- /dev/null
+++ b/django-extensions-fix-django6-regressions.diff
@@ -0,0 +1,90 @@
+--- a/django_extensions/db/fields/__init__.py
++++ b/django_extensions/db/fields/__init__.py
+@@ -87,7 +87,11 @@ class UniqueFieldMixin:
+ 
+         new = next(iterator)
+         kwargs[self.attname] = new
+-        while not new or queryset.filter(query, **kwargs):
++        while True:
++            matching = queryset.filter(query, **kwargs)
++            has_match = matching.exists() if hasattr(matching, "exists") else bool(matching)
++            if new and not has_match:
++                break
+             new = next(iterator)
+             kwargs[self.attname] = new
+         setattr(model_instance, self.attname, new)
+@@ -389,10 +393,14 @@ class RandomCharField(UniqueFieldMixin,
+         return False
+ 
+     def pre_save(self, model_instance, add):
+-        if (not add or self.keep_default) and getattr(
+-            model_instance, self.attname
+-        ) != "":
+-            return getattr(model_instance, self.attname)
++        current_value = getattr(model_instance, self.attname)
++        # Django 6 may call pre_save multiple times for inserts; if we've already
++        # populated the field value, reuse it instead of regenerating.
++        if current_value not in ("", None):
++            return current_value
++
++        if (not add or self.keep_default) and current_value != "":
++            return current_value
+ 
+         population = ""
+         if self.include_alpha:
+--- a/django_extensions/management/commands/list_signals.py
++++ b/django_extensions/management/commands/list_signals.py
+@@ -53,7 +53,9 @@ class Command(BaseCommand):
+         for signal in signals:
+             signal_name = SIGNAL_NAMES.get(signal, "unknown")
+             for receiver in signal.receivers:
+-                if django.VERSION >= (5, 0):
++                if django.VERSION >= (6, 0):
++                    lookup, receiver, _sender, is_async = receiver
++                elif django.VERSION >= (5, 0):
+                     lookup, receiver, is_async = receiver
+                 else:
+                     lookup, receiver = receiver
+--- a/tests/test_management_command.py
++++ b/tests/test_management_command.py
+@@ -4,6 +4,7 @@ from unittest import mock
+ import logging
+ import importlib
+ 
++import django
+ from django.core.management import (
+     call_command,
+     find_commands,
+@@ -422,7 +423,10 @@ class ListModelInfoTests(TestCase):
+             stdout=out,
+         )
+         self.output = out.getvalue()
+-        self.assertIn("id - AutoField", self.output)
++        if django.VERSION >= (6, 0):
++            self.assertIn("id - BigAutoField", self.output)
++        else:
++            self.assertIn("id - AutoField", self.output)
+         self.assertIn("char_field - CharField", self.output)
+         self.assertIn("integer_field - IntegerField", self.output)
+         self.assertIn("foreign_key_field - ForeignKey", self.output)
+--- a/tests/testapp/models.py
++++ b/tests/testapp/models.py
+@@ -1,4 +1,5 @@
+ # -*- coding: utf-8 -*-
++import django
+ from django.db import models
+ from django.contrib.auth import get_user_model
+ from django.db.models import UniqueConstraint
+@@ -179,7 +180,11 @@ class PostWithUniqField(models.Model):
+                 fields=("common_field", "uniq_field"), name="unique_common_uniq_pair"
+             ),
+             models.CheckConstraint(
+-                check=~models.Q(common_field=models.F("another_common_field")),
++                **(
++                    {"condition": ~models.Q(common_field=models.F("another_common_field"))}
++                    if django.VERSION >= (5, 2)
++                    else {"check": ~models.Q(common_field=models.F("another_common_field"))}
++                ),
+                 name="common_and_another_common_differ",
+             ),
+         ]

diff --git a/python-django-extensions.spec b/python-django-extensions.spec
index e826c71..f498206 100644
--- a/python-django-extensions.spec
+++ b/python-django-extensions.spec
@@ -1,5 +1,7 @@
 # Build doc by default
-%bcond_without doc
+%bcond doc 1
+
+%bcond pypi_source 0
 
 %global srcname django-extensions
 %global modname django_extensions
@@ -11,9 +13,14 @@ Summary:        Extensions for Django
 
 License:        GPL-3.0-or-later
 URL:            https://github.com/django-extensions/django-extensions
+%if %{with pypi_source}
 # PyPI tarball doesn't contain some requirements files
-# Source0:        %%{pypi_source %%{srcname}}
-Source0:        %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
+Source:         %{pypi_source %{srcname}}
+%else
+Source:         %{url}/archive/%{version}/%{srcname}-%{version}.tar.gz
+%endif
+# Backported from https://github.com/django-extensions/django-extensions/pull/1979
+Patch:          %{srcname}-fix-django6-regressions.diff
 
 BuildArch:      noarch
 

diff --git a/series b/series
new file mode 100644
index 0000000..6b4f785
--- /dev/null
+++ b/series
@@ -0,0 +1 @@
+django-extensions-fix-django6-regressions.diff

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-16 17:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-16 17:15 [rpms/python-django-extensions] rawhide: Backport fix for Django 6 support regressions; Fixes rhbz#2458683 Michel Lind

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox