repo stringclasses 1
value | instance_id stringlengths 20 20 | base_commit stringlengths 40 40 | patch stringlengths 356 10.7k | test_patch stringlengths 540 11.2k | problem_statement stringlengths 146 5.34k | hints_text stringlengths 0 6.77k | created_at stringdate 2022-04-09 09:38:31 2023-07-17 16:54:19 | version stringclasses 3
values | FAIL_TO_PASS stringlengths 39 2.25k | PASS_TO_PASS stringlengths 2 30.1k | environment_setup_commit stringclasses 3
values | difficulty stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
django/django | django__django-15572 | 0b31e024873681e187b574fe1c4afe5e48aeeecf | diff --git a/django/template/autoreload.py b/django/template/autoreload.py
--- a/django/template/autoreload.py
+++ b/django/template/autoreload.py
@@ -17,7 +17,7 @@ def get_template_directories():
if not isinstance(backend, DjangoTemplates):
continue
- items.update(cwd / to_path(dir) for ... | diff --git a/tests/template_tests/test_autoreloader.py b/tests/template_tests/test_autoreloader.py
--- a/tests/template_tests/test_autoreloader.py
+++ b/tests/template_tests/test_autoreloader.py
@@ -81,6 +81,17 @@ def test_reset_all_loaders(self, mock_reset):
autoreload.reset_loaders()
self.assertEqua... | Django 3.2.4+ autoreload breaks on empty string in TEMPLATES DIRS.
Description
Django versions > 3.2.3 changes the way template dirs are handled, they are now normalized using pathlib.Path.
People having an invalid value in TEMPLATESDIRS? will notice that autoreload stops working.
"DIRS": os.getenv("TEMPLATES_DIRS", ... | 2022-04-09T09:38:31Z | 4.1 | ["test_template_dirs_ignore_empty_path (template_tests.test_autoreloader.TemplateReloadTests)"] | ["test_get_template_directories (template_tests.test_autoreloader.Jinja2TemplateReloadTests)", "test_reset_all_loaders (template_tests.test_autoreloader.Jinja2TemplateReloadTests)", "test_watch_for_template_changes (template_tests.test_autoreloader.Jinja2TemplateReloadTests)", "test_get_template_directories (template_t... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | <15 min fix | |
django/django | django__django-15629 | 694cf458f16b8d340a3195244196980b2dec34fd | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -823,13 +823,15 @@ def _alter_field(
self.execute(self._delete_unique_sql(model, constraint_name))
# Drop incoming FK constraint... | diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -65,6 +65,16 @@ def assertColumnNull(self, table, column, using="default"):
def assertColumnNotNull(self, table, column, using="default"):
self.assertFalse(... | Errors with db_collation – no propagation to foreignkeys
Description
(last modified by typonaut)
Using db_collation with a pk that also has referenced fks in other models causes foreign key constraint errors in MySQL.
With the following models:
class Account(models.Model):
id = ShortUUIDField(primary_key=True,... | It seems like this should be addressable by defining a ForeignKey.db_collation property that proxies self.target_field.db_column django/db/models/fields/related.py diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 11407ac902..f82f787f5c 100644 a b def db_type(self, connection):... | 2022-04-23T21:58:24Z | 4.1 | ["AlterField operation of db_collation on primary keys changes any FKs", "Creation of models with a FK to a PK with db_collation."] | ["test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.FieldOperationTests)", "test_references_field_by_remote_field_model (migrations.... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 1-4 hours |
django/django | django__django-15695 | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -960,6 +960,9 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state):
else:
... | diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -2988,6 +2988,11 @@ def test_rename_index_unnamed_index(self):
with connection.schema_editor() as editor, self.assertNumQueries(0):
... | RenameIndex() crashes when unnamed index is moving backward and forward.
Description
RenameIndex() should restore the old auto-generated name when an unnamed index for unique_together is moving backward. Now re-applying RenameIndex() crashes. For example:
tests/migrations/test_operations.py
diff --git a/tests/migrati... | I understand the issue that arises when one reverses a RenameIndex, but it was made "on purpose" somehow. In https://code.djangoproject.com/ticket/27064, For backwards operations with unnamed old indexes, RenameIndex is a noop. From my understanding, when an unnamed index becomes "named", the idea was that it remained ... | 2022-05-16T07:58:51Z | 4.1 | ["test_rename_index_unnamed_index (migrations.test_operations.OperationTests)"] | ["test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.FieldOperationTests)", "test_references_field_by_remote_field_model (migrations.... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
django/django | django__django-15731 | 93cedc82f29076c824d476354527af1150888e4f | diff --git a/django/db/models/manager.py b/django/db/models/manager.py
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -1,5 +1,6 @@
import copy
import inspect
+from functools import wraps
from importlib import import_module
from django.db import router
@@ -81,11 +82,10 @@ def check(self, **... | diff --git a/tests/basic/tests.py b/tests/basic/tests.py
--- a/tests/basic/tests.py
+++ b/tests/basic/tests.py
@@ -1,3 +1,4 @@
+import inspect
import threading
from datetime import datetime, timedelta
from unittest import mock
@@ -736,6 +737,17 @@ def test_manager_methods(self):
sorted(self.QUERYSET_PRO... | inspect.signature() returns incorrect signature on manager methods.
Description
(last modified by Shiva Kumar)
inspect.signature returns incorrect signature information when used on queryset methods
import inspect
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=100)
... | Tentatively accepted.
PR: https://github.com/django/django/pull/15731 | 2022-05-24T12:30:05Z | 4.2 | ["test_manager_method_signature (basic.tests.ManagerTest)"] | ["test_autofields_generate_different_values_for_each_instance (basic.tests.ModelInstanceCreationTests)", "test_can_create_instance_using_kwargs (basic.tests.ModelInstanceCreationTests)", "You can initialize a model instance using positional arguments,", "You can leave off the value for an AutoField when creating an", "... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-15732 | ce69e34bd646558bb44ea92cecfd98b345a0b3e0 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -528,7 +528,10 @@ def alter_unique_together(self, model, old_unique_together, new_unique_together)
# Deleted uniques
for fields in olds.... | diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -2809,6 +2809,69 @@ def test_alter_unique_together_remove(self):
operation.describe(), "Alter unique_together for Pony (0 constraint(... | Cannot drop unique_together constraint on a single field with its own unique=True constraint
Description
I have an erroneous unique_together constraint on a model's primary key (unique_together = (('id',),)) that cannot be dropped by a migration. Apparently the migration tries to find all unique constraints on the co... | Can you share a traceback that shows how and where the migration fails, please.
Here it is: Traceback (most recent call last): File "./bin/django", line 56, in <module> sys.exit(djangorecipe.manage.main('project.settings.local.foobar')) File "/foo/bar/eggs/djangorecipe-1.10-py2.7.egg/djangorecipe/manage.py", line 9, in... | 2022-05-24T12:58:31Z | 4.2 | ["test_remove_unique_together_on_unique_field (migrations.test_operations.OperationTests)"] | ["test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.FieldOperationTests)", "test_references_field_by_remote_field_model (migrations.... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-15741 | 8c0886b068ba4e224dd78104b93c9638b860b398 | diff --git a/django/utils/formats.py b/django/utils/formats.py
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -113,6 +113,7 @@ def get_format(format_type, lang=None, use_l10n=None):
use_l10n = settings.USE_L10N
if use_l10n and lang is None:
lang = get_language()
+ format_ty... | diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1518,6 +1518,9 @@ def test_get_format_modules_lang(self):
with translation.override("de", deactivate=True):
self.assertEqual(".", get_format("DECIMAL_SEPARATOR", lang="en"))
+ def te... | django.utils.formats.get_format should allow lazy parameter
Description
Commit [659d2421c7adb] (fixing #20296) triggered a regression when the date template filter (possibly others are affected too) receives a lazy string, like in some_date|date:_('Y-m-d').
This fails with: TypeError: getattr(): attribute name must b... | 2022-05-28T09:52:42Z | 4.2 | ["test_date_lazy (template_tests.filter_tests.test_date.DateTests)", "test_get_format_lazy_format (i18n.tests.FormattingTests)"] | ["test_lazy (i18n.tests.TestModels)", "test_safestr (i18n.tests.TestModels)", "get_language_info return the first fallback language info if the lang_info", "test_localized_language_info (i18n.tests.TestLanguageInfo)", "test_unknown_language_code (i18n.tests.TestLanguageInfo)", "test_unknown_language_code_and_country_co... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-15814 | 5eb6a2b33d70b9889e1cafa12594ad6f80773d3a | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -748,6 +748,7 @@ def deferred_to_data(self, target):
cur_model = source.related_model
else:
cur_model = source.... | diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py
--- a/tests/proxy_models/tests.py
+++ b/tests/proxy_models/tests.py
@@ -395,6 +395,12 @@ def test_proxy_load_from_fixture(self):
p = MyPerson.objects.get(pk=100)
self.assertEqual(p.name, "Elvis Presley")
+ def test_select_rela... | QuerySet.only() after select_related() crash on proxy models.
Description
When I optimize a query using select_related() and only() methods from the proxy model I encounter an error:
Windows 10; Python 3.10; Django 4.0.5
Traceback (most recent call last):
File "D:\study\django_college\manage.py", line 22, in <module... | Thanks for the report. Would you like to prepare a patch? A regression test is required, e.g. tests/proxy_models/tests.py diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index f2f465678b..2081c0cbe3 100644 a b class ProxyModelTests(TestCase): 390390 repr(resp), "<ProxyImprovement: ProxyImprovemen... | 2022-07-03T19:10:56Z | 4.2 | ["test_select_related_only (proxy_models.tests.ProxyModelTests)"] | ["test_abstract_base_with_model_fields (proxy_models.tests.ProxyModelTests)", "Creating a Person makes them accessible through the MyPerson proxy.", "A new MyPerson also shows up as a standard Person.", "test_concrete_model (proxy_models.tests.ProxyModelTests)", "test_content_type (proxy_models.tests.ProxyModelTests)",... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-15851 | b4817d20b9e55df30be0b1b2ca8c8bb6d61aab07 | diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -32,9 +32,9 @@ def settings_to_cmd_args_env(cls, settings_dict, parameters):
args += ["-h", host]
if port:
... | diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py
--- a/tests/dbshell/test_postgresql.py
+++ b/tests/dbshell/test_postgresql.py
@@ -154,7 +154,7 @@ def test_accent(self):
def test_parameters(self):
self.assertEqual(
self.settings_to_cmd_args_env({"NAME": "dbname... | dbshell additional parameters should be passed before dbname on PostgreSQL.
Description
psql expects all options to proceed the database name, if provided. So, if doing something like `./manage.py dbshell -- -c "select * from some_table;" one will get this:
$ ./manage.py dbshell -- -c "select * from some_table;"
psql... | 2022-07-18T01:36:33Z | 4.2 | ["test_parameters (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)"] | ["test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_column (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_crash_password_does_not_leak (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "t... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-15863 | 37c5b8c07be104fd5288cd87f101e48cb7a40298 | diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -149,7 +149,7 @@ def floatformat(text, arg=-1):
use_l10n = False
arg = arg[:-1] or -1
try:
- input_val = repr(text)
... | diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
--- a/tests/template_tests/filter_tests/test_floatformat.py
+++ b/tests/template_tests/filter_tests/test_floatformat.py
@@ -56,6 +56,10 @@ def test_inputs(self):
self.assertEqual(floatform... | Filter floatformat drops precision in decimal numbers
Description
I discovered that floatformat template filter may drop precision when used for Decimal numbers.
MWE:
from decimal import Decimal
from django import setup
from django.conf import settings
from django.template import Template, Context
TEMPLATES = [
{
... | 2022-07-20T12:58:04Z | 4.2 | ["test_inputs (template_tests.filter_tests.test_floatformat.FunctionTests)"] | ["test_floatformat01 (template_tests.filter_tests.test_floatformat.FloatformatTests)", "test_floatformat02 (template_tests.filter_tests.test_floatformat.FloatformatTests)", "test_float_dunder_method (template_tests.filter_tests.test_floatformat.FunctionTests)", "test_force_grouping (template_tests.filter_tests.test_flo... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-15916 | 88e67a54b7ed0210c11523a337b498aadb2f5187 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -253,18 +253,11 @@ def __init__(self, options=None):
self.help_texts = getattr(options, "help_texts", None)
self.error_messages = getattr(options, "error_messages", None)
... | diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -3496,6 +3496,41 @@ class InheritedForm(NewForm):
type(NewForm.base_fields[name].widget),
)
+ def test_custom_callback_in_meta(self):
+ def ... | Allow ModelForm meta to specify formfield_callback.
Description
(last modified by Klaas-Jan Gorter)
The function django.forms.modelform_factory returns a form class based on the class it recieves as form argument. As an additional argument it accepts a formfield_callback function. When no callback is provided t... | I was always the impression that formfield_callback was solely an allowed kwarg of the modelform_factory function and its friends. I believe this test has been removed from version 2, because I find no equivalent test in tests/model_formsets_regress. From what I can see the patch from #18573 was never committed and thu... | 2022-08-04T18:59:18Z | 4.2 | ["test_custom_callback_from_base_form_meta (model_forms.tests.FormFieldCallbackTests)", "test_custom_callback_in_meta (model_forms.tests.FormFieldCallbackTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "Regression test for #12960. Make sure the cleaned_data returned from", "Regression for #12596: Calling super from ModelForm.clean() should be", "test_bad_callback (model_forms.tests.FormFieldCallbackTests)", "Using base forms with widgets... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-15930 | 63884829acd207404f2a5c3cc1d6b4cd0a822b70 | diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -1299,6 +1299,11 @@ def as_sql(self, compiler, connection, template=None, **extra_context):
template_params = extra_context
sql_params = []
... | diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py
--- a/tests/expressions_case/tests.py
+++ b/tests/expressions_case/tests.py
@@ -415,6 +415,16 @@ def test_annotate_with_empty_when(self):
self.assertEqual(len(objects), CaseTestModel.objects.count())
self.assertTrue(all(obj... | Case() crashes with ~Q(pk__in=[]).
Description
The following code generates a syntax error.
User.objects.annotate(
_a=Case(
When(~Q(pk__in=[]), then=Value(True)),
default=Value(False),
output_field=BooleanField(),
)
).order_by("-a").values("pk")
The error is:
ProgrammingError: syntax error at or near "THEN"... | Thanks for the report (similar to the #33374 and #26517). | 2022-08-07T15:26:41Z | 4.2 | ["test_annotate_with_full_when (expressions_case.tests.CaseExpressionTests)"] | ["test_empty_q_object (expressions_case.tests.CaseWhenTests)", "test_invalid_when_constructor_args (expressions_case.tests.CaseWhenTests)", "test_only_when_arguments (expressions_case.tests.CaseWhenTests)", "test_conditional_aggregation_example (expressions_case.tests.CaseDocumentationExamples)", "test_conditional_upda... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-15957 | f387d024fc75569d2a4a338bfda76cc2f328f627 | diff --git a/django/db/models/fields/related_descriptors.py b/django/db/models/fields/related_descriptors.py
--- a/django/db/models/fields/related_descriptors.py
+++ b/django/db/models/fields/related_descriptors.py
@@ -64,8 +64,10 @@ class Child(Model):
"""
from django.core.exceptions import FieldError
-from django... | diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py
--- a/tests/prefetch_related/tests.py
+++ b/tests/prefetch_related/tests.py
@@ -1908,3 +1908,67 @@ def test_nested_prefetch_is_not_overwritten_by_related_object(self):
self.assertIs(Room.house.is_cached(self.room), True)
wi... | Prefetch objects don't work with slices
Description
Prefetch() objects does not work with sliced querysets. For example the following code results in AssertionError: Cannot filter a query once a slice has been taken.:
Category.objects.prefetch_related(Prefetch(
'post_set',
queryset=Post.objects.all()[:3],
to_attr... | It seems to me that #26565 ("Allow Prefetch query to use .values()") is related.
Hi ludwik, #26565 is about a different issue. The only way we could support slices would be to extract it from the provided queryset to make it filterable again and apply it when in-memory joining. The prefect queryset would still have to ... | 2022-08-13T06:18:25Z | 4.2 | ["test_foreignkey_reverse (prefetch_related.tests.PrefetchLimitTests)", "test_m2m_forward (prefetch_related.tests.PrefetchLimitTests)", "test_m2m_reverse (prefetch_related.tests.PrefetchLimitTests)", "test_reverse_ordering (prefetch_related.tests.PrefetchLimitTests)"] | ["The prefetched relationship is used rather than populating the reverse", "test_bug (prefetch_related.tests.Ticket19607Tests)", "When intermediary results are prefetched without a destination", "In-bulk does correctly prefetch objects by not using .iterator()", "test_prefetch_nullable (prefetch_related.tests.NullableT... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 1-4 hours |
django/django | django__django-15973 | 2480554dc4ada4ecf3f6a08e318735a2e50783f3 | diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -1422,7 +1422,7 @@ def _get_dependencies_for_foreign_key(app_label, model_name, field, project_stat
dependencies = [(dep_app_label, d... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -3585,6 +3585,52 @@ def test_create_with_through_model(self):
changes, "testapp", 0, 3, model_name="author", name="publishers... | Defining the "through" model in a many-to-many field in another app causes "AttributeError: 'str' object has no attribute '_meta'" on migration
Description
I tried migrating my apps into the database, the three relevant apps are called: "fonte", "fonte_variavel" and "variavel". fonte and variavel models have a many-t... | I was able to reproduce the problem with your models. Moving the FonteVariavelModel model to the fonte app seems to work. Even if there's a bug in Django, as a workaround, why not simply move the model? | 2022-08-19T18:10:02Z | 4.2 | ["test_create_with_through_model_separate_apps (migrations.test_autodetector.AutodetectorTests)"] | ["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-15987 | 7e6b537f5b92be152779fc492bb908d27fe7c52a | diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -367,7 +367,7 @@ def fixture_dirs(self):
for app_config in apps.get_app_configs():
app_label... | diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py
--- a/tests/fixtures_regress/tests.py
+++ b/tests/fixtures_regress/tests.py
@@ -569,6 +569,20 @@ def test_fixture_dirs_with_default_fixture_path(self):
with self.assertRaisesMessage(ImproperlyConfigured, msg):
managemen... | Fixture dirs duplicates undetected if dir is Path instance
Description
When FIXTURE_DIRS contains Path instances, the duplicate check in loaddata does not detect duplicates.
| 2022-08-23T10:07:03Z | 4.2 | ["settings.FIXTURE_DIRS cannot contain a default fixtures directory"] | ["test_fixtures_loaded (fixtures_regress.tests.TestLoadFixtureFromOtherAppDirectory)", "Natural keys with foreing keys in dependencies works in a multiple", "M2M relations with explicit through models should NOT count as", "Circular M2M relations with explicit through models should be serializable", "M2M relations with... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-16032 | 0c3981eb5094419fe200eb46c71b5376a2266166 | diff --git a/django/db/models/fields/related_lookups.py b/django/db/models/fields/related_lookups.py
--- a/django/db/models/fields/related_lookups.py
+++ b/django/db/models/fields/related_lookups.py
@@ -93,7 +93,6 @@ def get_prep_lookup(self):
elif not getattr(self.rhs, "has_select_fields", True) and not g... | diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -989,6 +989,34 @@ def test_annotation_filter_with_subquery(self):
publisher_books_qs, [{"name": "Sams"}, {"name": "Morgan Kaufmann"}]
)
+ def test_annotati... | __in doesn't clear selected fields on the RHS when QuerySet.alias() is used after annotate().
Description
Here is a test case to reproduce the bug, you can add this in tests/annotations/tests.py
def test_annotation_and_alias_filter_in_subquery(self):
long_books_qs = (
Book.objects.filter(
pages__gt=400,
... | This is a documented and expected behavior.
Using either .alias or .annotate works as expected without using .values to limit to 1 column. Why is that? but using both of them doesn't seem work.
Replying to Gabriel Muj: Using either .alias or .annotate works as expected without using .values to limit to 1 column. Why i... | 2022-09-06T09:54:57Z | 4.2 | ["test_annotation_and_alias_filter_in_subquery (annotations.tests.NonAggregateAnnotationTestCase)", "test_annotation_and_alias_filter_related_in_subquery (annotations.tests.NonAggregateAnnotationTestCase)"] | ["test_aggregate_alias (annotations.tests.AliasTests)", "test_alias_after_annotation (annotations.tests.AliasTests)", "test_alias_annotate_with_aggregation (annotations.tests.AliasTests)", "test_alias_annotation_expression (annotations.tests.AliasTests)", "test_alias_default_alias_expression (annotations.tests.AliasTes... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16082 | bf47c719719d0e190a99fa2e7f959d5bbb7caf8a | diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -533,6 +533,7 @@ def __hash__(self):
Combinable.SUB,
Combinable.MUL,
Combinable.DIV,
+ Combinable.MOD,
... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -2416,7 +2416,13 @@ def test_resolve_output_field_number(self):
(IntegerField, FloatField, FloatField),
(FloatField, IntegerField, FloatField),
]
-... | Resolve output_field when combining numeric expressions with MOD operator.
Description
When writing a Django expression for a query that does MOD, if the types of the query are different (Decimal and Integer), it doesn't resolve the result to a Decimal type, like it does for other mathematical operators.
| Duplicate of #33397.
I'm pretty sure the changes committed as part of #33397, while closely related, doesn't actually address this case. I think it's best to handle this as a separate ticket.
Hasn't this been addressed by https://github.com/django/django/pull/15271/files#diff-359ab56295cce36b9597e1d65185f695f271955617... | 2022-09-21T18:49:40Z | 4.2 | ["test_resolve_output_field_number (expressions.tests.CombinedExpressionTests)", "test_resolve_output_field_with_null (expressions.tests.CombinedExpressionTests)"] | ["test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_equal_Value (expressions.tests.FTests)", "test_equal (expressions.tests.OrderByTests)", "test_hash (expressions.tests.OrderByTests)", "te... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16100 | c6350d594c359151ee17b0c4f354bb44f28ff69e | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -2011,15 +2011,17 @@ def changelist_view(self, request, extra_context=None):
)
if formset.is_valid():
changecount = 0
-... | diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -1,4 +1,5 @@
import datetime
+from unittest import mock
from django.contrib import admin
from django.contrib.admin.models import LogEntry
@@ -16,12 +17,12 @@... | Add transaction handling to Changelist list_editable processing.
Description
It seems that changelist_view in Django admin is missing a transaction. Since the view may change data in database, it should be wrapped in a transaction to prevent unexpected states in case of errors.
| So, this has never been wrapped in a transaction. See https://github.com/django/django/commit/7bc0878922 where it was added. Happy to accept as a New Feature to investigate adding that. (I can't immediately see any obvious blockers.) | 2022-09-24T13:32:02Z | 4.2 | ["test_list_editable_atomicity (admin_changelist.tests.ChangeListTests)"] | ["{% get_admin_log %} works if the user model's primary key isn't named", "test_missing_args (admin_changelist.tests.GetAdminLogTests)", "{% get_admin_log %} works without specifying a user.", "test_non_integer_limit (admin_changelist.tests.GetAdminLogTests)", "test_without_as (admin_changelist.tests.GetAdminLogTests)"... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16116 | 5d36a8266c7d5d1994d7a7eeb4016f80d9cb0401 | diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -70,7 +70,10 @@ def add_arguments(self, parser):
"--check",
acti... | diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -2391,9 +2391,10 @@ def test_makemigrations_check(self):
makemigrations --check should exit with a non-zero status when
there are change... | makemigrations --check generating migrations is inconsistent with other uses of --check
Description
To script a check for missing migrations but without actually intending to create the migrations, it is necessary to use both --check and --dry-run, which is inconsistent with migrate --check and optimizemigration --ch... | I think this makes sense. | 2022-09-25T23:54:49Z | 4.2 | ["makemigrations --check should exit with a non-zero status when"] | ["test_makemigrations_app_name_specified_as_label (migrations.test_commands.AppLabelErrorTests)", "test_makemigrations_nonexistent_app_label (migrations.test_commands.AppLabelErrorTests)", "test_migrate_app_name_specified_as_label (migrations.test_commands.AppLabelErrorTests)", "test_migrate_nonexistent_app_label (migr... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16136 | 19e6efa50b603af325e7f62058364f278596758f | diff --git a/django/views/generic/base.py b/django/views/generic/base.py
--- a/django/views/generic/base.py
+++ b/django/views/generic/base.py
@@ -148,7 +148,16 @@ def http_method_not_allowed(self, request, *args, **kwargs):
request.path,
extra={"status_code": 405, "request": request},
... | diff --git a/tests/async/tests.py b/tests/async/tests.py
--- a/tests/async/tests.py
+++ b/tests/async/tests.py
@@ -6,8 +6,8 @@
from django.core.cache import DEFAULT_CACHE_ALIAS, caches
from django.core.exceptions import ImproperlyConfigured, SynchronousOnlyOperation
-from django.http import HttpResponse
-from djang... | object HttpResponseNotAllowed can't be used in 'await' expression
Description
When defining a simple View subclass with only an async "post" method, GET requests to this view cause the following exception:
[29/Sep/2022 07:50:48] "GET /demo HTTP/1.1" 500 81134
Method Not Allowed (GET): /demo
Internal Server Error: /de... | Yes, looks right. http_method_not_allowed() needs to be adjusted to handle both sync and async cases in the same way as options() Do you have capacity to do a patch quickly? (Otherwise I'll take it on.) Thanks for the report! Regression in 9ffd4eae2ce7a7100c98f681e2b6ab818df384a4.
Thank you very much for your confirmat... | 2022-09-29T11:47:50Z | 4.2 | ["test_http_method_not_allowed_responds_correctly (async.tests.ViewTests)", "test_mixed_views_raise_error (async.tests.ViewTests)"] | ["View and by extension any subclasses that don't define handlers are", "test_options_handler_responds_correctly (async.tests.ViewTests)", "test_views_are_correctly_marked (async.tests.ViewTests)", "test_caches_local (async.tests.CacheTest)", "test_async_unsafe (async.tests.AsyncUnsafeTest)", "Utility class which turns... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16139 | d559cb02da30f74debbb1fc3a46de0df134d2d80 | diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -163,7 +163,9 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
password = self.fields.get("password")
if password:
- ... | diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -1,5 +1,6 @@
import datetime
import re
+import urllib.parse
from unittest import mock
from django.contrib.auth.forms import (
@@ -22,6 +23,7 @@
from django.for... | Accessing UserAdmin via to_field leads to link to PasswordResetForm being broken (404)
Description
(last modified by Simon Kern)
Accessing the UserAdmin via another model's Admin that has a reference to User (with to_field set, e.g., to_field="uuid") leads to the UserAdmin being accessed via an url that looks s... | 2022-09-30T08:51:16Z | 4.2 | ["test_link_to_password_reset_in_helptext_via_to_field (auth_tests.test_forms.UserChangeFormTest)"] | ["test_field_order (auth_tests.test_forms.PasswordChangeFormTest)", "test_html_autocomplete_attributes (auth_tests.test_forms.PasswordChangeFormTest)", "test_incorrect_password (auth_tests.test_forms.PasswordChangeFormTest)", "test_password_verification (auth_tests.test_forms.PasswordChangeFormTest)", "test_password_wh... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-16145 | 93d4c9ea1de24eb391cb2b3561b6703fd46374df | diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
--- a/django/core/management/commands/runserver.py
+++ b/django/core/management/commands/runserver.py
@@ -129,6 +129,13 @@ def inner_run(self, *args, **options):
shutdown_message = options.get("shutdown_mes... | diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1587,6 +1587,21 @@ def test_runserver_addrport(self):
call_command(self.cmd, addrport="7000")
self.assertServerSettings("127.0.0.1", "7000")
+ @mock.p... | `runserver 0`'s "Starting development server at <address>" doesn't work
Description
According to tutorial running
python manage.py runserver 0:8000
is the same as
python manage.py runserver 0.0.0.0:8000
but it's output
$ python manage.py runserver 0:8000 Watching for file changes with StatReloader ... | On a Mac I could click that link and have it take me to http://0.0.0.0:8000/ What OS are you on? It might even be better to just explicitly change it to say "0.0.0.0" because at least then you can copy & paste it as well … Let's wait to see what the triage team decide 🤷♂️
According to the Diátaxis framework, a tuto... | 2022-10-03T05:09:14Z | 4.2 | ["test_zero_ip_addr (admin_scripts.tests.ManageRunserver)"] | ["Program name is computed from the execute_from_command_line()'s argv", "test_params_to_runserver (admin_scripts.tests.ManageTestserver)", "test_testserver_handle_params (admin_scripts.tests.ManageTestserver)", "test_migration_warning_multiple_apps (admin_scripts.tests.ManageRunserverMigrationWarning)", "test_migratio... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16255 | 444b6da7cc229a58a2c476a52e45233001dc7073 | diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
--- a/django/contrib/sitemaps/__init__.py
+++ b/django/contrib/sitemaps/__init__.py
@@ -167,7 +167,7 @@ def get_latest_lastmod(self):
return None
if callable(self.lastmod):
try:
- ret... | diff --git a/tests/sitemaps_tests/test_http.py b/tests/sitemaps_tests/test_http.py
--- a/tests/sitemaps_tests/test_http.py
+++ b/tests/sitemaps_tests/test_http.py
@@ -507,6 +507,16 @@ def test_callable_sitemod_full(self):
self.assertXMLEqual(index_response.content.decode(), expected_content_index)
sel... | Sitemaps without items raise ValueError on callable lastmod.
Description
When sitemap contains not items, but supports returning lastmod for an item, it fails with a ValueError:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
res... | Thanks for the report.
The default argument of max() can be used. | 2022-11-04T13:49:40Z | 4.2 | ["test_callable_sitemod_no_items (sitemaps_tests.test_http.HTTPSitemapTests)"] | ["A simple sitemap index can be rendered with a custom template", "test_simple_sitemap_custom_index_warning (sitemaps_tests.test_http.DeprecatedTests)", "A i18n sitemap with alternate/hreflang links can be rendered.", "A i18n sitemap index with limited languages can be rendered.", "A i18n sitemap index with x-default c... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16256 | 76e37513e22f4d9a01c7f15eee36fe44388e6670 | diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py
--- a/django/contrib/contenttypes/fields.py
+++ b/django/contrib/contenttypes/fields.py
@@ -2,6 +2,8 @@
import itertools
from collections import defaultdict
+from asgiref.sync import sync_to_async
+
from django.contrib.conte... | diff --git a/tests/async/models.py b/tests/async/models.py
--- a/tests/async/models.py
+++ b/tests/async/models.py
@@ -9,3 +9,7 @@ class RelatedModel(models.Model):
class SimpleModel(models.Model):
field = models.IntegerField()
created = models.DateTimeField(default=timezone.now)
+
+
+class ManyToManyModel(m... | acreate(), aget_or_create(), and aupdate_or_create() doesn't work as intended on related managers.
Description
Async-compatible interface was added to QuerySet in 58b27e0dbb3d31ca1438790870b2b51ecdb10500. Unfortunately, it also added (unintentionally) async acreate(), aget_or_create(), and aupdate_or_create() methods... | Jon, would you like to prepare a patch? (against the main branch.)
Yeah I can take care of that. I’ll be traveling for the next 2 days then recovering from jetlag and then back on the road again, so I just want to set expectations that this won’t be immediate :(
Replying to Jon Janzen: Yeah I can take care of that. I’l... | 2022-11-04T14:26:44Z | 4.2 | ["test_acreate (async.test_async_related_managers.AsyncRelatedManagersOperationTest)", "test_acreate_reverse (async.test_async_related_managers.AsyncRelatedManagersOperationTest)", "test_aget_or_create (async.test_async_related_managers.AsyncRelatedManagersOperationTest)", "test_aget_or_create_reverse (async.test_async... | ["test_none_allowed (generic_relations.tests.TestInitWithNoneArgument)", "The default for for_concrete_model should be True", "test_generic_relation (generic_relations.tests.ProxyRelatedModelTest)", "test_generic_relation_set (generic_relations.tests.ProxyRelatedModelTest)", "Instances of the proxy should be returned w... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16263 | 321ecb40f4da842926e1bc07e11df4aabe53ca4b | diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -405,6 +405,12 @@ def replace_expressions(self, replacements):
)
return clone
+ def get_refs(self):
+ refs = set()
+ for expr... | diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -34,6 +34,7 @@
Cast,
Coalesce,
Greatest,
+ Lower,
Now,
Pi,
TruncDate,
@@ -2084,3 +2085,41 @@ def test_exists_extra_where_with_aggregate(self):
... | Strip unused annotations from count queries
Description
The query below produces a SQL statement that includes the Count('chapters'), despite not not being used in any filter operations.
Book.objects.annotate(Count('chapters')).count()
It produces the same results as:
Book.objects.count()
Django could be more intelli... | Same can be done for exists()
WIP PR: https://github.com/django/django/pull/8928/files
The PR is still marked [WIP] and there are test failures.
I have also run into problems with QuerySet.count() being very slow on annotated query sets. Django uses a subquery for the count but injects a group by into the subquery. Th... | 2022-11-06T07:38:18Z | 4.2 | ["test_non_aggregate_annotation_pruned (aggregation.tests.AggregateAnnotationPruningTests)", "test_unreferenced_aggregate_annotation_pruned (aggregation.tests.AggregateAnnotationPruningTests)", "test_unused_aliased_aggregate_pruned (aggregation.tests.AggregateAnnotationPruningTests)"] | ["test_referenced_aggregate_annotation_kept (aggregation.tests.AggregateAnnotationPruningTests)", "test_add_implementation (aggregation.tests.AggregateTestCase)", "test_aggregate_alias (aggregation.tests.AggregateTestCase)", "test_aggregate_annotation (aggregation.tests.AggregateTestCase)", "test_aggregate_in_order_by ... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 1-4 hours |
django/django | django__django-16315 | 7d5329852f19c6ae78c6f6f3d3e41835377bf295 | diff --git a/django/db/models/query.py b/django/db/models/query.py
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -720,7 +720,6 @@ def _check_bulk_create_options(
"Unique fields that can trigger the upsert must be provided."
)
# Updating primary key... | diff --git a/tests/bulk_create/models.py b/tests/bulk_create/models.py
--- a/tests/bulk_create/models.py
+++ b/tests/bulk_create/models.py
@@ -69,6 +69,11 @@ class TwoFields(models.Model):
name = models.CharField(max_length=15, null=True)
+class FieldsWithDbColumns(models.Model):
+ rank = models.IntegerFiel... | QuerySet.bulk_create() crashes on mixed case columns in unique_fields/update_fields.
Description
Not sure exactly how to phrase this, but when I I'm calling bulk_update on the manager for a class with db_column set on fields the SQL is invalid. Ellipses indicate other fields excluded for clarity.
class ActivityBlackL... | Thanks for the report! Bug in 0f6946495a8ec955b471ca1baaf408ceb53d4796. We should use columns instead of field names, e.g. django/db/models/query.py diff --git a/django/db/models/query.py b/django/db/models/query.py index de49e1c58c..fcf0a0616c 100644 a b class QuerySet(AltersData): 798798 self._prepare_for_bulk_create... | 2022-11-22T09:44:54Z | 4.2 | ["test_update_conflicts_unique_fields_update_fields_db_column (bulk_create.tests.BulkCreateTests)"] | ["test_batch_same_vals (bulk_create.tests.BulkCreateTests)", "test_bulk_insert_expressions (bulk_create.tests.BulkCreateTests)", "test_bulk_insert_nullable_fields (bulk_create.tests.BulkCreateTests)", "test_efficiency (bulk_create.tests.BulkCreateTests)", "test_empty_model (bulk_create.tests.BulkCreateTests)", "test_ex... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16333 | 60a7bd89860e504c0c33b02c78edcac87f6d1b5a | diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -141,6 +141,8 @@ def save(self, commit=True):
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
+ if hasattr(... | diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -35,6 +35,7 @@
)
from .models.with_custom_email_field import CustomEmailField
from .models.with_integer_username import IntegerUsernameUser
+from .models.with_many... | UserCreationForm should save data from ManyToMany form fields
Description
When using contrib.auth.forms.UserCreationForm with a custom User model which has ManyToManyField fields, the data in all related form fields (e.g. a ModelMultipleChoiceField) is not saved.
This is because unlike its parent class django.forms.... | 2022-11-27T20:09:15Z | 4.2 | ["test_custom_form_saves_many_to_many_field (auth_tests.test_forms.UserCreationFormTest)"] | ["test_field_order (auth_tests.test_forms.PasswordChangeFormTest)", "test_html_autocomplete_attributes (auth_tests.test_forms.PasswordChangeFormTest)", "test_incorrect_password (auth_tests.test_forms.PasswordChangeFormTest)", "test_password_verification (auth_tests.test_forms.PasswordChangeFormTest)", "test_password_wh... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-16429 | 6c86495bcee22eac19d7fb040b2988b830707cbd | diff --git a/django/utils/timesince.py b/django/utils/timesince.py
--- a/django/utils/timesince.py
+++ b/django/utils/timesince.py
@@ -97,6 +97,7 @@ def timesince(d, now=None, reversed=False, time_strings=None, depth=2):
d.hour,
d.minute,
d.second,
+ tzinfo=d.tzinfo,
... | diff --git a/tests/utils_tests/test_timesince.py b/tests/utils_tests/test_timesince.py
--- a/tests/utils_tests/test_timesince.py
+++ b/tests/utils_tests/test_timesince.py
@@ -1,7 +1,7 @@
import datetime
from django.test import TestCase
-from django.test.utils import requires_tz_support
+from django.test.utils impor... | timesince() raises TypeError with USE_TZ=True and >1 month interval.
Description
(last modified by Sage Abdullah)
As of 8d67e16493c903adc9d049141028bc0fff43f8c8, calling timesince() with a datetime object that's one month (or more) in the past and the USE_TZ setting is set to True results in the following crash... | Thanks for the report, however test_long_interval_with_tz works for me on the current main branch 🤔
Whoops, sorry, I haven't properly tested the function as I currently don't have a local Django dev environment. I'm testing this on a shell with my Django project, I think this should be reproducible: >>> from django.ut... | 2023-01-05T11:41:37Z | 4.2 | ["test_depth (utils_tests.test_timesince.TZAwareTimesinceTests)", "test_depth_invalid (utils_tests.test_timesince.TZAwareTimesinceTests)", "Test other units.", "test_thousand_years_ago (utils_tests.test_timesince.TZAwareTimesinceTests)"] | ["Timesince should work with both date objects (#9672)", "Both timesince and timeuntil should work on date objects (#17937).", "When using two different timezones.", "If the two differing units aren't adjacent, only the first unit is", "When the second date occurs before the first, we should always", "equal datetimes."... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16454 | 1250483ebf73f7a82ff820b94092c63ce4238264 | diff --git a/django/core/management/base.py b/django/core/management/base.py
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -6,6 +6,7 @@
import os
import sys
from argparse import ArgumentParser, HelpFormatter
+from functools import partial
from io import TextIOBase
import django
@@ ... | diff --git a/tests/user_commands/management/commands/subparser_vanilla.py b/tests/user_commands/management/commands/subparser_vanilla.py
new file mode 100644
--- /dev/null
+++ b/tests/user_commands/management/commands/subparser_vanilla.py
@@ -0,0 +1,13 @@
+import argparse
+
+from django.core.management.base import Base... | Management command subparsers don’t retain error formatting
Description
Django management commands use a subclass of argparse.ArgumentParser, CommandParser, that takes some extra arguments to improve error formatting. These arguments are not copied into subparsers, created via CommandParser.add_subparsers().add_parse... | 2023-01-15T09:23:24Z | 5.0 | ["test_subparser_error_formatting (user_commands.tests.CommandRunTests.test_subparser_error_formatting)"] | ["test_get_random_secret_key (user_commands.tests.UtilsTests.test_get_random_secret_key)", "test_is_ignored_path_false (user_commands.tests.UtilsTests.test_is_ignored_path_false)", "test_is_ignored_path_true (user_commands.tests.UtilsTests.test_is_ignored_path_true)", "test_no_existent_external_program (user_commands.t... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour | |
django/django | django__django-16485 | 39f83765e12b0e5d260b7939fc3fe281d879b279 | diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -168,7 +168,7 @@ def floatformat(text, arg=-1):
except (ValueError, OverflowError, InvalidOperation):
return input_val
- if not m and p... | diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
--- a/tests/template_tests/filter_tests/test_floatformat.py
+++ b/tests/template_tests/filter_tests/test_floatformat.py
@@ -111,6 +111,8 @@ def test_zero_values(self):
self.assertEqual(
... | floatformat() crashes on "0.00".
Description
from decimal import Decimal
from django.template.defaultfilters import floatformat
floatformat('0.00', 0)
floatformat(Decimal('0.00'), 0)
Both throw ValueError: valid range for prec is [1, MAX_PREC]
| Thanks for the report and testing against the alpha release! Regression in 08c5a787262c1ae57f6517d4574b54a5fcaad124. | 2023-01-18T22:03:52Z | 5.0 | ["test_zero_values (template_tests.filter_tests.test_floatformat.FunctionTests.test_zero_values)"] | ["test_floatformat01 (template_tests.filter_tests.test_floatformat.FloatformatTests.test_floatformat01)", "test_floatformat02 (template_tests.filter_tests.test_floatformat.FloatformatTests.test_floatformat02)", "test_float_dunder_method (template_tests.filter_tests.test_floatformat.FunctionTests.test_float_dunder_metho... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16493 | e3a4cee081cf60650b8824f0646383b79cb110e7 | diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -295,8 +295,9 @@ def deconstruct(self):
if kwargs.get("max_length") == 100:
del kwargs["max_length"]
kwargs["upload_to"] = self... | diff --git a/tests/file_storage/models.py b/tests/file_storage/models.py
--- a/tests/file_storage/models.py
+++ b/tests/file_storage/models.py
@@ -9,7 +9,7 @@
import tempfile
from pathlib import Path
-from django.core.files.storage import FileSystemStorage
+from django.core.files.storage import FileSystemStorage, d... | Callable storage on FileField fails to deconstruct when it returns default_storage
Description
If the storage argument on a FileField is set to a callable that returns default_storage, it is omitted from the deconstructed form of the field, rather than being included as a reference to the callable as expected.
For ex... | Yes, OK. That looks correct. We're essentially saying that when hasattr(self, "_storage_callable") that should unconditionally be used by deconstruct. 🤔
We should probably use getattr(self, "_storage_callable", self.storage) in both lines. | 2023-01-20T18:29:25Z | 5.0 | ["A callable that returns default_storage is not omitted when"] | ["test_deconstruction (file_storage.tests.FileSystemStorageTests.test_deconstruction)", "FileSystemStorage.__init__() shouldn't evaluate base_url.", "test_deprecation_warning (file_storage.tests.GetStorageClassTests.test_deprecation_warning)", "get_storage_class returns the class for a storage backend name/path.", "get... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16502 | 246eb4836a6fb967880f838aa0d22ecfdca8b6f1 | diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -11,6 +11,7 @@
import socket
import socketserver
import sys
+from collections import deque
from wsgiref import simple_server
from django.core.exceptions im... | diff --git a/tests/servers/test_basehttp.py b/tests/servers/test_basehttp.py
--- a/tests/servers/test_basehttp.py
+++ b/tests/servers/test_basehttp.py
@@ -1,4 +1,5 @@
from io import BytesIO
+from socketserver import ThreadingMixIn
from django.core.handlers.wsgi import WSGIRequest
from django.core.servers.basehttp ... | After #26052 runserver returns response body for HTTP HEAD requests
Description
For compliance with RFC 2616, section 4.3, response bodies must not be returned for HEAD requests.
In #26052, the stripping of the response bodies was removed from Django in favour of letting the server perform the body removal, since the... | Also this comment now seems incorrect: https://github.com/django/django/blob/5d3b322dce452dd75e8602ced9f0d02f9d6a5837/django/middleware/http.py#L15-L19 ...in that the body won't be empty as far as middleware is concerned for HEAD requests. The spec says entity tag validators can still be set for HEAD requests: https:... | 2023-01-26T09:21:31Z | 5.0 | ["test_no_body_returned_for_head_requests (servers.test_basehttp.WSGIRequestHandlerTestCase.test_no_body_returned_for_head_requests)"] | ["test_https (servers.test_basehttp.WSGIRequestHandlerTestCase.test_https)", "test_log_message (servers.test_basehttp.WSGIRequestHandlerTestCase.test_log_message)", "WSGIRequestHandler ignores headers containing underscores.", "WSGIServer handles broken pipe errors."] | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16527 | bd366ca2aeffa869b7dbc0b0aa01caea75e6dc31 | diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py
--- a/django/contrib/admin/templatetags/admin_modify.py
+++ b/django/contrib/admin/templatetags/admin_modify.py
@@ -100,7 +100,7 @@ def submit_row(context):
and context.get("show_delete", ... | diff --git a/tests/admin_views/test_templatetags.py b/tests/admin_views/test_templatetags.py
--- a/tests/admin_views/test_templatetags.py
+++ b/tests/admin_views/test_templatetags.py
@@ -3,6 +3,7 @@
from django.contrib.admin import ModelAdmin
from django.contrib.admin.templatetags.admin_list import date_hierarchy
fr... | "show_save_as_new" in admin can add without this permission
Description
(last modified by Mariusz Felisiak)
At "django/contrib/admin/templatetags/admin_modify.py" file, line 102, I think you must put one more verification for this tag: "and has_add_permission", because "save_as_new" is a add modification.
I rew... | Thanks for the report. It was previously reported in #5650 and #3817, and #3817 was closed but only with a fix for "Save and add another" (see 825f0beda804e48e9197fcf3b0d909f9f548aa47). I rewrite this for my project: "show_save_as_new": not is_popup and has_add_permission # This line that I put!!! and has_change_permis... | 2023-02-05T22:05:00Z | 5.0 | ["test_submit_row_save_as_new_add_permission_required (admin_views.test_templatetags.AdminTemplateTagsTest.test_submit_row_save_as_new_add_permission_required)"] | ["test_choice_links (admin_views.test_templatetags.DateHierarchyTests.test_choice_links)", "test_choice_links_datetime (admin_views.test_templatetags.DateHierarchyTests.test_choice_links_datetime)", "admin_modify template tags follow the standard search pattern", "admin_list template tags follow the standard search pat... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16560 | 51c9bb7cd16081133af4f0ab6d06572660309730 | diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -32,6 +32,7 @@ def __init__(
condition=None,
deferrable=None,
include=None,
+ violation_error_code=N... | diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
--- a/tests/constraints/tests.py
+++ b/tests/constraints/tests.py
@@ -77,17 +77,26 @@ def test_custom_violation_error_message_clone(self):
"custom base_name message",
)
+ def test_custom_violation_code_message(self):
+ ... | Allow to customize the code attribute of ValidationError raised by BaseConstraint.validate
Description
It is currently possible to customize the violation_error_message of a ValidationError raised by a constraint but not the code.
I'd like to add a new violation_error_message parameter to BaseConstraint to allow to e... | Replying to xafer: It is currently possible to customize the violation_error_message of a ValidationError raised by a constraint but not the code. I'd like to add a new violation_error_message parameter to BaseConstraint to allow to easily add one. Agreed, adding violation_error_code sounds like a good idea as we have ... | 2023-02-16T10:45:56Z | 5.0 | ["test_custom_violation_code_message (constraints.tests.BaseConstraintTests.test_custom_violation_code_message)", "test_deconstruction (constraints.tests.BaseConstraintTests.test_deconstruction)", "test_eq (constraints.tests.CheckConstraintTests.test_eq)", "test_repr_with_violation_error_code (constraints.tests.CheckCo... | ["test_constraint_sql (constraints.tests.BaseConstraintTests.test_constraint_sql)", "test_contains_expressions (constraints.tests.BaseConstraintTests.test_contains_expressions)", "test_create_sql (constraints.tests.BaseConstraintTests.test_create_sql)", "test_custom_violation_error_message (constraints.tests.BaseConstr... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 1-4 hours |
django/django | django__django-16569 | 278881e37619278789942513916acafaa88d26f3 | diff --git a/django/forms/formsets.py b/django/forms/formsets.py
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -490,7 +490,9 @@ def add_fields(self, form, index):
required=False,
widget=self.get_ordering_widget(),
)
- if self.can_delet... | diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -1480,6 +1480,7 @@ def test_disable_delete_extra_formset_forms(self):
self.assertIn("DELETE", formset.forms[0].fields... | Formsets' add_fields() method fails in some circumstances if the argument index is None.
Description
Formsets' add_fields() method fails in some circumstances if the argument index is None.
When a FormSet has the attributes self.can_delete == True and self.can_delete_extra == False, calling the add_fields() method on... | 2023-02-17T20:11:38Z | 5.0 | ["test_disable_delete_extra_formset_forms (forms_tests.tests.test_formsets.FormsFormsetTestCase.test_disable_delete_extra_formset_forms)", "test_disable_delete_extra_formset_forms (forms_tests.tests.test_formsets.Jinja2FormsFormsetTestCase.test_disable_delete_extra_formset_forms)"] | ["all_valid() validates all forms, even when some are invalid.", "test_valid (forms_tests.tests.test_formsets.AllValidTests.test_valid)", "is_multipart() works with an empty formset.", "An empty formset still calls clean()", "Media is available on empty formset.", "test_as_div (forms_tests.tests.test_formsets.FormsetAs... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix | |
django/django | django__django-16595 | f9fe062de5fc0896d6bbbf3f260b5c44473b3c77 | diff --git a/django/db/migrations/operations/fields.py b/django/db/migrations/operations/fields.py
--- a/django/db/migrations/operations/fields.py
+++ b/django/db/migrations/operations/fields.py
@@ -247,9 +247,9 @@ def migration_name_fragment(self):
return "alter_%s_%s" % (self.model_name_lower, self.name_lowe... | diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py
--- a/tests/migrations/test_optimizer.py
+++ b/tests/migrations/test_optimizer.py
@@ -221,10 +221,10 @@ def test_create_alter_owrt_delete_model(self):
migrations.AlterOrderWithRespectTo("Foo", "a")
)
- def _t... | Migration optimizer does not reduce multiple AlterField
Description
Let's consider the following operations:
operations = [
migrations.AddField(
model_name="book",
name="title",
field=models.CharField(max_length=256, null=True),
),
migrations.AlterField(
model_name="book",
name="title",
field=models.C... | Your analysis is correct Laurent, the reduction of multiple AlterField against the same model is simply not implemented today hence why you're running into this behaviour. Given you're already half way there I would encourage you to submit a PR that adds these changes and an optimizer regression test to cover them if... | 2023-02-24T10:30:35Z | 5.0 | ["test_alter_alter_field (migrations.test_optimizer.OptimizerTests.test_alter_alter_field)"] | ["AlterField should optimize into AddField.", "RemoveField should cancel AddField", "RenameField should optimize into AddField", "test_alter_alter_index_model (migrations.test_optimizer.OptimizerTests.test_alter_alter_index_model)", "test_alter_alter_owrt_model (migrations.test_optimizer.OptimizerTests.test_alter_alter... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix |
django/django | django__django-16612 | 55bcbd8d172b689811fae17cde2f09218dd74e9c | diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -453,7 +453,9 @@ def catch_all_view(self, request, url):
pass
else:
if getattr(match.func, "should_append_slash", True):
- ... | diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -8463,6 +8463,24 @@ def test_missing_slash_append_slash_true(self):
response, known_url, status_code=301, target_status_code=403
)
+ @override_settings(APP... | AdminSite.catch_all_view() drops query string in redirects
Description
#31747 introduced AdminSite.catch_all_view(). However, in the process it broke the ability to redirect with settings.APPEND_SLASH = True when there are query strings.
Provided URL: http://127.0.0.1:8000/admin/auth/foo?id=123
Expected redirect: h... | Thanks for the report! Using get_full_path() should fix the issue: django/contrib/admin/sites.py diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index 61be31d890..96c54e44ad 100644 a b class AdminSite: 453453 pass 454454 else: 455455 if getattr(match.func, "should_append_slash", True): 456 re... | 2023-03-02T19:06:12Z | 5.0 | ["test_missing_slash_append_slash_true_query_string (admin_views.tests.AdminSiteFinalCatchAllPatternTests.test_missing_slash_append_slash_true_query_string)", "test_missing_slash_append_slash_true_script_name_query_string (admin_views.tests.AdminSiteFinalCatchAllPatternTests.test_missing_slash_append_slash_true_script_... | ["test_explicitly_provided_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest.test_explicitly_provided_pk)", "test_implicitly_generated_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest.test_implicitly_generated_pk)", "test_secure_view_shows_login_if_not_logged_in (admin_views.tests.SecureViewTests.test_se... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16631 | 9b224579875e30203d079cc2fee83b116d98eb78 | diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
--- a/django/contrib/auth/__init__.py
+++ b/django/contrib/auth/__init__.py
@@ -199,12 +199,26 @@ def get_user(request):
# Verify the session
if hasattr(user, "get_session_auth_hash"):
session_hash ... | diff --git a/tests/auth_tests/test_basic.py b/tests/auth_tests/test_basic.py
--- a/tests/auth_tests/test_basic.py
+++ b/tests/auth_tests/test_basic.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.contrib.auth import get_user, get_user_model
from django.contrib.auth.models import AnonymousUser, User
... | SECRET_KEY_FALLBACKS is not used for sessions
Description
I recently rotated my secret key, made the old one available in SECRET_KEY_FALLBACKS and I'm pretty sure everyone on our site is logged out now.
I think the docs for SECRET_KEY_FALLBACKS may be incorrect when stating the following:
In order to rotate your sec... | Hi! I'm a colleague of Eric's, and we were discussing some of the ramifications of fixing this issue and I thought I'd write them here for posterity. In particular for user sessions, using fallback keys in the AuthenticationMiddleware/auth.get_user(request) will keep existing _auth_user_hash values from before the rota... | 2023-03-06T15:19:52Z | 5.0 | ["test_get_user_fallback_secret (auth_tests.test_basic.TestGetUser.test_get_user_fallback_secret)"] | ["test_get_user (auth_tests.test_basic.TestGetUser.test_get_user)", "test_get_user_anonymous (auth_tests.test_basic.TestGetUser.test_get_user_anonymous)", "The current user model can be retrieved", "Check the creation and properties of a superuser", "test_superuser_no_email_or_password (auth_tests.test_basic.BasicTestC... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 1-4 hours |
django/django | django__django-16642 | fbe850106b2e4b85f838219cb9e1df95fba6c164 | diff --git a/django/http/response.py b/django/http/response.py
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -609,7 +609,9 @@ def set_headers(self, filelike):
# Encoding isn't set to prevent browsers from automatically
# uncompressing files.
content_ty... | diff --git a/tests/responses/test_fileresponse.py b/tests/responses/test_fileresponse.py
--- a/tests/responses/test_fileresponse.py
+++ b/tests/responses/test_fileresponse.py
@@ -253,8 +253,10 @@ def test_compressed_response(self):
"""
test_tuples = (
(".tar.gz", "application/gzip"),
+ ... | Improper guessing of Mime Type for "br" and "Z" file types
Description
Below FileResponse will set the content type as text/html, even if the last file extension is "Z' or "br".
FileResponse(open('test.html.Z', 'rb'))
FileResponse(open('test.html.br', 'rb'))
| Thanks for the report! | 2023-03-11T07:38:47Z | 5.0 | ["If compressed responses are served with the uncompressed Content-Type"] | ["Headers are set correctly with a buffer when an absolute filename is", "test_content_disposition_buffer (responses.test_fileresponse.FileResponseTests.test_content_disposition_buffer)", "test_content_disposition_buffer_attachment (responses.test_fileresponse.FileResponseTests.test_content_disposition_buffer_attachmen... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix |
django/django | django__django-16661 | d687febce5868545f99974d2499a91f81a32fef5 | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -461,12 +461,14 @@ def lookup_allowed(self, lookup, value):
# Lookups on nonexistent fields are ok, since they're ignored
# late... | diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py
--- a/tests/modeladmin/tests.py
+++ b/tests/modeladmin/tests.py
@@ -154,6 +154,35 @@ class EmployeeProfileAdmin(ModelAdmin):
ma.lookup_allowed("employee__department__code", "test_value"), True
)
+ @isolate_apps("modeladmin")
+... | ModelAdmin.lookup_allowed() incorrectly raises DisallowedModelAdminLookup lookup with foreign key as primary key
Description
(last modified by Tim Graham)
Wrote a failing test for tests/modeladmin/tests.py to demonstrate - same test/code passes on 1.8
@isolate_apps('modeladmin')
def test_lookup_allowed_foreign_... | Bisected to 8f30556329b64005d63b66859a74752a0b261315. | 2023-03-18T09:26:58Z | 5.0 | ["test_lookup_allowed_foreign_primary (modeladmin.tests.ModelAdminTests.test_lookup_allowed_foreign_primary)"] | ["has_add_permission returns True for users who can add objects and", "has_change_permission returns True for users who can edit objects and", "has_delete_permission returns True for users who can delete objects and", "as_module_permission returns True for users who have any permission", "has_view_permission() returns ... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16662 | 0eb3e9bd754e4c9fac8b616b705178727fc8031e | diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py
--- a/django/db/migrations/writer.py
+++ b/django/db/migrations/writer.py
@@ -175,7 +175,10 @@ def as_string(self):
# Sort imports by the package / module to be imported (the part after
# "from" in "from ... import ..." or ... | diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -7,6 +7,7 @@
import pathlib
import re
import sys
+import time
import uuid
import zoneinfo
from types import NoneType
@@ -912,13 +913,18 @@ def test_sorted_i... | Migration import ordering violates coding style and isort defaults
Description
New migration files are generated with imports sorted by module, independent of import style. For example:
import datetime
from django.db import migrations, models
import time
The Django coding style specifies:
Place all import module sta... | Normally I would reject this ticket as migrations are auto-generated code and it's not worth adding complicated logic to make them fully isort-compatible. However, this is a small tweak, so I'm happy to make it a slightly more accurate. Please send patch via a GitHub PR. | 2023-03-18T18:07:18Z | 5.0 | ["#24155 - Tests ordering of imports."] | ["test_args_kwargs_signature (migrations.test_writer.OperationWriterTests.test_args_kwargs_signature)", "test_args_signature (migrations.test_writer.OperationWriterTests.test_args_signature)", "test_empty_signature (migrations.test_writer.OperationWriterTests.test_empty_signature)", "test_expand_args_signature (migrati... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16667 | 02c356f2f3945b8075735d485c3cf48cad991011 | diff --git a/django/forms/widgets.py b/django/forms/widgets.py
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -1161,6 +1161,8 @@ def value_from_datadict(self, data, files, name):
# Return pseudo-ISO dates with zeros for any unselected values,
# e.g. '2017-0-23'.
... | diff --git a/tests/forms_tests/field_tests/test_datefield.py b/tests/forms_tests/field_tests/test_datefield.py
--- a/tests/forms_tests/field_tests/test_datefield.py
+++ b/tests/forms_tests/field_tests/test_datefield.py
@@ -1,3 +1,4 @@
+import sys
from datetime import date, datetime
from django.core.exceptions impor... | SelectDateWidget can crash with OverflowError.
Description
Given a relatively common view like this:
from django import forms
from django.forms import SelectDateWidget
from django.http import HttpResponse
class ReproForm(forms.Form):
my_date = forms.DateField(widget=SelectDateWidget())
def repro_view(request):
fo... | patch
Thanks for this report. | 2023-03-20T21:32:53Z | 5.0 | ["test_form_field (forms_tests.field_tests.test_datefield.DateFieldTest.test_form_field)", "test_value_from_datadict (forms_tests.widget_tests.test_selectdatewidget.SelectDateWidgetTest.test_value_from_datadict)"] | ["test_datefield_1 (forms_tests.field_tests.test_datefield.DateFieldTest.test_datefield_1)", "test_datefield_2 (forms_tests.field_tests.test_datefield.DateFieldTest.test_datefield_2)", "test_datefield_3 (forms_tests.field_tests.test_datefield.DateFieldTest.test_datefield_3)", "test_datefield_4 (forms_tests.field_tests.... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16801 | 3b62d8c83e3e48d2ed61cfa32a61c56d9e030293 | diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -441,7 +441,8 @@ def contribute_to_class(self, cls, name, **kwargs):
# after their corresponding image field don't stay cleared by
# Model._... | diff --git a/tests/model_fields/test_imagefield.py b/tests/model_fields/test_imagefield.py
--- a/tests/model_fields/test_imagefield.py
+++ b/tests/model_fields/test_imagefield.py
@@ -5,6 +5,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.files import File
from django.core.files.images i... | ImageField unnecessarily adds a post_init signal handler to the model
Description
While debugging some performance issues in a Django app, I found a codepath where most of the time was being spent on initializing Django models after fetching from the DB. It turns out that 30% of the time was being spent on evaluating... | 2023-04-26T07:23:56Z | 5.0 | ["test_post_init_not_connected (model_fields.test_imagefield.ImageFieldNoDimensionsTests.test_post_init_not_connected)"] | ["Assigning ImageField to None clears dimensions.", "Tests assigning an image field through the model's constructor.", "Tests assigning an image in Manager.create().", "The default value for an ImageField is an instance of", "Dimensions are updated correctly in various situations.", "Tests assignment using the field's ... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix | |
django/django | django__django-16819 | 0b0998dc151feb77068e2387c34cc50ef6b356ae | diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -861,6 +861,11 @@ def describe(self):
def migration_name_fragment(self):
return "%s_%s" % (self.model_name_l... | diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py
--- a/tests/migrations/test_optimizer.py
+++ b/tests/migrations/test_optimizer.py
@@ -1158,3 +1158,17 @@ def test_rename_index(self):
),
]
)
+
+ def test_add_remove_index(self):
+ self.a... | Reduce Add/RemoveIndex migration operations.
Description
We should reduce AddIndex/RemoveIndex operations when optimizing migration operations.
| 2023-05-01T15:20:04Z | 5.0 | ["test_add_remove_index (migrations.test_optimizer.OptimizerTests.test_add_remove_index)"] | ["AlterField should optimize into AddField.", "RemoveField should cancel AddField", "RenameField should optimize into AddField", "test_alter_alter_field (migrations.test_optimizer.OptimizerTests.test_alter_alter_field)", "test_alter_alter_index_model (migrations.test_optimizer.OptimizerTests.test_alter_alter_index_mode... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour | |
django/django | django__django-16877 | 98f6ada0e2058d67d91fb6c16482411ec2ca0967 | diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -444,6 +444,16 @@ def escape_filter(value):
return conditional_escape(value)
+@register.filter(is_safe=True)
+def escapeseq(value):
+ """
+ ... | diff --git a/tests/template_tests/filter_tests/test_escapeseq.py b/tests/template_tests/filter_tests/test_escapeseq.py
new file mode 100644
--- /dev/null
+++ b/tests/template_tests/filter_tests/test_escapeseq.py
@@ -0,0 +1,59 @@
+from django.test import SimpleTestCase
+from django.utils.safestring import mark_safe
+
+f... | New template filter `escapeseq`
Description
Following #34574, and after some conversations within the security team, it seems appropriate to provide a new template filter escapeseq which would be to escape what safeseq is to safe. An example of usage would be:
{{ some_list|escapeseq|join:"," }}
where each item of som... | 2023-05-19T23:11:10Z | 5.0 | ["test_autoescape_off (template_tests.filter_tests.test_escapeseq.EscapeseqTests.test_autoescape_off)", "test_basic (template_tests.filter_tests.test_escapeseq.EscapeseqTests.test_basic)", "test_chain_join (template_tests.filter_tests.test_escapeseq.EscapeseqTests.test_chain_join)", "test_chain_join_autoescape_off (tem... | [] | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour | |
django/django | django__django-16899 | d3d173425fc0a1107836da5b4567f1c88253191b | diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -771,10 +771,11 @@ def _check_readonly_fields_item(self, obj, field_name, label):
except FieldDoesNotExist:
return [
... | diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -798,8 +798,9 @@ class SongAdmin(admin.ModelAdmin):
errors = SongAdmin(Song, AdminSite()).check()
expected = [
checks.Error(
- "The ... | ModelAdmin: Error message for readonly_fields's check does not include the field name
Description
When subclassing a ModelAdmin, the current error message for the readonly_fields would indicate the index of the value at fault but it will not include the field's name (from the test suite):
The value of 'readonly_field... | 2023-05-26T13:41:37Z | 5.0 | ["test_nonexistent_field (admin_checks.tests.SystemChecksTestCase.test_nonexistent_field)", "test_nonexistent_field_on_inline (admin_checks.tests.SystemChecksTestCase.test_nonexistent_field_on_inline)"] | ["test_admin_check_ignores_import_error_in_middleware (admin_checks.tests.SystemChecksTestCase.test_admin_check_ignores_import_error_in_middleware)", "test_allows_checks_relying_on_other_modeladmins (admin_checks.tests.SystemChecksTestCase.test_allows_checks_relying_on_other_modeladmins)", "test_app_label_in_admin_chec... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix | |
django/django | django__django-16901 | ee36e101e8f8c0acde4bb148b738ab7034e902a0 | diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -6,6 +6,7 @@
from django.core.exceptions import EmptyResultSet, FullResultSet
from django.db.models.expressions import Case, When
+from django.db.models.functions imp... | diff --git a/tests/xor_lookups/tests.py b/tests/xor_lookups/tests.py
--- a/tests/xor_lookups/tests.py
+++ b/tests/xor_lookups/tests.py
@@ -19,6 +19,27 @@ def test_filter(self):
self.numbers[:3] + self.numbers[8:],
)
+ def test_filter_multiple(self):
+ qs = Number.objects.filter(
+ ... | On databases lacking XOR, Q(…) ^ Q(…) ^ Q(…) wrongly interpreted as exactly-one rather than parity
Description
On databases that don’t natively support XOR, such as PostgreSQL, Django generates incorrect fallback SQL for Q(…) ^ Q(…) ^ Q(…) with more than 2 arguments. The correct interpretation, and the interpretatio... | 2023-05-30T05:08:34Z | 5.0 | ["test_filter_multiple (xor_lookups.tests.XorLookupsTests.test_filter_multiple)"] | ["test_empty_in (xor_lookups.tests.XorLookupsTests.test_empty_in)", "test_exclude (xor_lookups.tests.XorLookupsTests.test_exclude)", "test_filter (xor_lookups.tests.XorLookupsTests.test_filter)", "test_filter_negated (xor_lookups.tests.XorLookupsTests.test_filter_negated)", "test_pk_q (xor_lookups.tests.XorLookupsTests... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour | |
django/django | django__django-16938 | 1136aa5005f0ae70fea12796b7e37d6f027b9263 | diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
--- a/django/core/serializers/python.py
+++ b/django/core/serializers/python.py
@@ -79,7 +79,9 @@ def m2m_value(value):
return self._value_from_field(value, value._meta.pk)
def queryset_iterator(ob... | diff --git a/tests/serializers/models/base.py b/tests/serializers/models/base.py
--- a/tests/serializers/models/base.py
+++ b/tests/serializers/models/base.py
@@ -53,12 +53,24 @@ def __str__(self):
return self.name
+class TopicManager(models.Manager):
+ def get_queryset(self):
+ return super().ge... | Serialization of m2m relation fails with custom manager using select_related
Description
Serialization of many to many relation with custom manager using select_related cause FieldError: Field cannot be both deferred and traversed using select_related at the same time. Exception is raised because performance optimali... | Thanks for the report! Regression in 19e0587ee596debf77540d6a08ccb6507e60b6a7. Reproduced at 4142739af1cda53581af4169dbe16d6cd5e26948.
Maybe we could clear select_related(): django/core/serializers/python.py diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py index 36048601af..5c6e1c2689 ... | 2023-06-03T11:18:11Z | 5.0 | ["The ability to create new objects by modifying serialized content.", "Deserialized content can be saved with force_insert as a parameter.", "Mapping such as fields should be deterministically ordered. (#24558)", "Year values before 1000AD are properly formatted", "Basic serialization works.", "test_serialize_no_only_... | ["test_stream_class (serializers.tests.SerializerAPITests.test_stream_class)", "test_lazy_string_encoding (serializers.test_json.DjangoJSONEncoderTests.test_lazy_string_encoding)", "test_timedelta (serializers.test_json.DjangoJSONEncoderTests.test_timedelta)", "Using yaml deserializer without pyyaml raises ImportError"... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16950 | f64fd47a7627ed6ffe2df2a32ded6ee528a784eb | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -1177,7 +1177,13 @@ def add_fields(self, form, index):
to_field = self.instance._meta.get_field(kwargs["to_field"])
else:
to_field = self.instance._met... | diff --git a/tests/model_formsets/test_uuid.py b/tests/model_formsets/test_uuid.py
--- a/tests/model_formsets/test_uuid.py
+++ b/tests/model_formsets/test_uuid.py
@@ -43,6 +43,8 @@ def test_inlineformset_factory_ignores_default_pks_on_submit(self):
}
)
self.assertTrue(formset.is_valid())
... | Django Admin with Inlines not using UUIDField default value
Description
(last modified by Joseph Metzinger)
Hello,
I am a long time django user, first time bug reporter, so please let me know if I need to do anything else to help get this bug fixed :)
I am using Django 3.1.3 and python 3.8.5 and have cerated a ... | I made a toy project containing all the code to reproduce the error and zipped it.
Thanks for the detailed report. I was able to reproduce this issue. It looks that formsets' validation mutates the main object, because new_object.id is not empty before the all_valid() call: >>> new_object.id e13fd82c-c3fc-42dc-ac12-57... | 2023-06-06T19:58:48Z | 5.0 | ["If form data is provided, a parent's auto-generated alternate key is"] | ["#24377 - Inlines with a model field default should ignore that default", "#24377 - If we're adding a new object, a parent's auto-generated pk", "#24958 - Variant of test_inlineformset_factory_nulls_default_pks for"] | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-17029 | 953f29f700a60fc09b08b2c2270c12c447490c6a | diff --git a/django/apps/registry.py b/django/apps/registry.py
--- a/django/apps/registry.py
+++ b/django/apps/registry.py
@@ -373,6 +373,7 @@ def clear_cache(self):
This is mostly used in tests.
"""
+ self.get_swappable_settings_name.cache_clear()
# Call expire cache on each model. ... | diff --git a/tests/apps/tests.py b/tests/apps/tests.py
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -197,6 +197,17 @@ def test_get_model(self):
with self.assertRaises(ValueError):
apps.get_model("admin_LogEntry")
+ @override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS)
+ def test... | Apps.clear_cache() does not clear get_swappable_settings_name cache.
Description
We use apps.clear_cache() in django-stubs to be able to reset the previous state on consequential mypy runs.
Code: https://github.com/typeddjango/django-stubs/pull/1601/files#diff-c49d8fe2cd0a58fad3c36ab3a88c7745e9622f3098e60cd512953eb1... | Thanks for the report, tentatively accepted. | 2023-06-29T13:18:26Z | 5.0 | ["test_clear_cache (apps.tests.AppsTests.test_clear_cache)"] | ["test_app_default_auto_field (apps.tests.AppConfigTests.test_app_default_auto_field)", "test_default_auto_field_setting (apps.tests.AppConfigTests.test_default_auto_field_setting)", "If single element in __path__, use it (in preference to __file__).", "If the __path__ attr contains duplicate paths and there is no", "I... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix |
django/django | django__django-17084 | f8c43aca467b7b0c4bb0a7fa41362f90b610b8df | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -403,6 +403,7 @@ def get_aggregation(self, using, aggregate_exprs):
# Store annotation mask prior to temporarily adding aggregations for
# resolving pur... | diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -28,6 +28,7 @@
Value,
Variance,
When,
+ Window,
)
from django.db.models.expressions import Func, RawSQL
from django.db.models.functions import (
@@ -2207,3 +2208... | Cannot use aggregate over window functions since 4.2
Description
(last modified by younes-chaoui)
After upgrading to Django 4.2, I encountered an exception when executing ORM queries that involve aggregates over Window functions. The specific error was psycopg2.errors.GroupingError: aggregate function calls can... | Hello! Could you please provide a minimal Django test project with models to reproduce this issue? Or a regression test that would pass on Django 4.1 but fail in 4.2? Thank you! | 2023-07-17T16:54:19Z | 5.0 | ["test_referenced_window_requires_wrapping (aggregation.tests.AggregateAnnotationPruningTests.test_referenced_window_requires_wrapping)"] | ["test_non_aggregate_annotation_pruned (aggregation.tests.AggregateAnnotationPruningTests.test_non_aggregate_annotation_pruned)", "test_referenced_aggregate_annotation_kept (aggregation.tests.AggregateAnnotationPruningTests.test_referenced_aggregate_annotation_kept)", "test_referenced_group_by_annotation_kept (aggregat... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.