public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Michel Lind <salimma@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/python-django-extensions] rawhide: Backport fix for Django 6 support regressions; Fixes rhbz#2458683
Date: Tue, 16 Jun 2026 17:15:06 GMT	[thread overview]
Message-ID: <178163010632.1.8416426562471712538.rpms-python-django-extensions-4b4327800747@fedoraproject.org> (raw)

            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

                 reply	other threads:[~2026-06-16 17:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178163010632.1.8416426562471712538.rpms-python-django-extensions-4b4327800747@fedoraproject.org \
    --to=salimma@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox