instance_id
stringlengths
18
32
text
stringlengths
4.44k
962k
repo
stringclasses
12 values
base_commit
stringlengths
40
40
problem_statement
stringlengths
143
24.8k
hints_text
stringlengths
0
15.4k
created_at
stringlengths
20
20
patch
stringlengths
294
17.4k
test_patch
stringlengths
367
26.6k
version
stringclasses
53 values
FAIL_TO_PASS
stringlengths
12
32.6k
PASS_TO_PASS
stringlengths
2
271k
environment_setup_commit
stringclasses
80 values
django__django-13128
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> make temporal subtraction work without ExpressionWrapper Description class Experiment(models.Model): start = models.DateTimeField() end = models.DateTimeField() Experiment.objects.annotate( delta=F('end') ...
django/django
2d67222472f80f251607ae1b720527afceba06ad
make temporal subtraction work without ExpressionWrapper Description class Experiment(models.Model): start = models.DateTimeField() end = models.DateTimeField() Experiment.objects.annotate( delta=F('end') - F('start') + Value(datetime.timedelta(), output_field=DurationField()) ) This gives: django.core.exceptions....
2020-06-30T18:06:56Z
<patch> 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 @@ -443,23 +443,6 @@ def set_source_expressions(self, exprs): self.lhs, self.rhs = exprs def as_sql(self, compiler, connection): - try...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1493,9 +1493,7 @@ def test_duration_expressions(self): @skipUnlessDBFeature('supports_temporal_subtraction') def test_date_subtraction(self): queryset = Experimen...
3.2
["test_date_case_subtraction (expressions.tests.FTimeDeltaTests)", "test_date_subquery_subtraction (expressions.tests.FTimeDeltaTests)", "test_date_subtraction (expressions.tests.FTimeDeltaTests)", "test_datetime_subquery_subtraction (expressions.tests.FTimeDeltaTests)", "test_datetime_subtraction_microseconds (express...
["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_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTest...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13158
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> QuerySet.none() on combined queries returns all results. Description I came across this issue on Stack Overflow. I'm not 100% sure it's a bug, but it does seem strange. With this code (excuse the bizarre exam...
django/django
7af8f4127397279d19ef7c7899e93018274e2f9b
QuerySet.none() on combined queries returns all results. Description I came across this issue on Stack Overflow. I'm not 100% sure it's a bug, but it does seem strange. With this code (excuse the bizarre example filtering): class Publication(models.Model): pass class Article(models.Model): publications = models.Man...
Thanks for the report. QuerySet.none() doesn't work properly on combined querysets, it returns all results instead of an empty queryset.
2020-07-06T19:18:11Z
<patch> 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 @@ -305,6 +305,7 @@ def clone(self): obj.annotation_select_mask = None else: obj.annotation_select_mask = self.annotation_select_m...
diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py --- a/tests/queries/test_qs_combinators.py +++ b/tests/queries/test_qs_combinators.py @@ -51,6 +51,13 @@ def test_union_distinct(self): self.assertEqual(len(list(qs1.union(qs2, all=True))), 20) self.assertEqual(le...
3.2
["test_union_none (queries.test_qs_combinators.QuerySetSetOperationTests)"]
["test_combining_multiple_models (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_difference (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_intersection (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_union (queries.test_qs_combinators.QuerySetSetOperati...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13195
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> HttpResponse.delete_cookie() should preserve cookie's samesite. Description We noticed we were getting this warning message from Firefox: 'Cookie “messages” will be soon rejected because it has the “sameSite”...
django/django
156a2138db20abc89933121e4ff2ee2ce56a173a
HttpResponse.delete_cookie() should preserve cookie's samesite. Description We noticed we were getting this warning message from Firefox: 'Cookie “messages” will be soon rejected because it has the “sameSite” attribute set to “none” or an invalid value, without the “secure” attribute. To know more about the “sameSite...
Thanks for this report, IMO we should add the samesite argument to delete_cookie() and preserve it for deleted cookies (see related #30862).
2020-07-15T11:00:07Z
<patch> diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py --- a/django/contrib/messages/storage/cookie.py +++ b/django/contrib/messages/storage/cookie.py @@ -92,7 +92,11 @@ def _update_cookie(self, encoded_data, response): samesite=settings.SESSION_COOKI...
diff --git a/tests/messages_tests/test_cookie.py b/tests/messages_tests/test_cookie.py --- a/tests/messages_tests/test_cookie.py +++ b/tests/messages_tests/test_cookie.py @@ -1,5 +1,6 @@ import json +from django.conf import settings from django.contrib.messages import constants from django.contrib.messages.storage...
3.2
["test_delete_cookie_samesite (responses.test_cookie.DeleteCookieTests)", "test_delete_cookie_secure_samesite_none (responses.test_cookie.DeleteCookieTests)", "test_session_delete_on_end (sessions_tests.tests.SessionMiddlewareTests)", "test_session_delete_on_end_with_custom_domain_and_path (sessions_tests.tests.Session...
["test_default (responses.test_cookie.DeleteCookieTests)", "test_delete_cookie_secure_prefix (responses.test_cookie.DeleteCookieTests)", "set_cookie() accepts an aware datetime as expiration time.", "Setting a cookie after deletion clears the expiry date.", "Cookie will expire when a distant expiration time is provided...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13212
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Make validators include the provided value in ValidationError Description It is sometimes desirable to include the provide value in a custom error message. For example: “blah” is not a valid email. By making ...
django/django
f4e93919e4608cfc50849a1f764fd856e0917401
Make validators include the provided value in ValidationError Description It is sometimes desirable to include the provide value in a custom error message. For example: “blah” is not a valid email. By making built-in validators provide value to ValidationError, one can override an error message and use a %(value)s pl...
​https://github.com/django/django/pull/13212 After reconsideration I have some doubts. Do you think it's really useful to include invalid values in error messages? Invalid form is redisplayed with errors in most (all?) of cases, so I'm not sure if it can be useful to display error messages containing invalid values nex...
2020-07-21T02:53:58Z
<patch> diff --git a/django/core/validators.py b/django/core/validators.py --- a/django/core/validators.py +++ b/django/core/validators.py @@ -48,7 +48,7 @@ def __call__(self, value): regex_matches = self.regex.search(str(value)) invalid_input = regex_matches if self.inverse_match else not regex_match...
diff --git a/tests/forms_tests/tests/test_validators.py b/tests/forms_tests/tests/test_validators.py --- a/tests/forms_tests/tests/test_validators.py +++ b/tests/forms_tests/tests/test_validators.py @@ -1,9 +1,11 @@ import re +import types from unittest import TestCase from django import forms from django.core im...
3.2
["test_value_placeholder_with_char_field (forms_tests.tests.test_validators.ValidatorCustomMessageTests)", "test_value_placeholder_with_decimal_field (forms_tests.tests.test_validators.ValidatorCustomMessageTests)", "test_value_placeholder_with_file_field (forms_tests.tests.test_validators.ValidatorCustomMessageTests)"...
["test_all_errors_get_reported (forms_tests.tests.test_validators.TestFieldWithValidators)", "test_field_validators_can_be_any_iterable (forms_tests.tests.test_validators.TestFieldWithValidators)"]
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13279
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Session data cannot be decoded during the transition to Django 3.1. Description In d4fff711d4c97356bd6ba1273d2a5e349326eb5f (#31274) we've changed format for session data, that's why setting DEFAULT_HASHING_A...
django/django
6e9c5ee88fc948e05b4a7d9f82a8861ed2b0343d
Session data cannot be decoded during the transition to Django 3.1. Description In d4fff711d4c97356bd6ba1273d2a5e349326eb5f (#31274) we've changed format for session data, that's why setting DEFAULT_HASHING_ALGORITHM to 'sha1' is not enough to support running multiple instances of the same project during the transiti...
2020-08-07T05:15:16Z
<patch> diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py --- a/django/contrib/sessions/backends/base.py +++ b/django/contrib/sessions/backends/base.py @@ -108,6 +108,9 @@ def _hash(self, value): def encode(self, session_dict): "Return the given session dic...
diff --git a/tests/sessions_tests/tests.py b/tests/sessions_tests/tests.py --- a/tests/sessions_tests/tests.py +++ b/tests/sessions_tests/tests.py @@ -31,9 +31,11 @@ from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation from django.http import HttpResponse from django.test import ( - Reques...
3.2
["test_default_hashing_algorith_legacy_decode (sessions_tests.tests.CookieSessionTests)", "test_default_hashing_algorith_legacy_decode (sessions_tests.tests.CacheSessionTests)", "test_default_hashing_algorith_legacy_decode (sessions_tests.tests.FileSessionTests)", "test_default_hashing_algorith_legacy_decode (sessions_...
["test_clear (sessions_tests.tests.CookieSessionTests)", "test_custom_expiry_datetime (sessions_tests.tests.CookieSessionTests)", "test_custom_expiry_reset (sessions_tests.tests.CookieSessionTests)", "test_custom_expiry_seconds (sessions_tests.tests.CookieSessionTests)", "test_custom_expiry_timedelta (sessions_tests.te...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13297
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> TemplateView.get_context_data()'s kwargs returns SimpleLazyObjects that causes a crash when filtering. Description Example Code that works in 3.0, but not in 3.1: class OfferView(TemplateView): template_name...
django/django
8954f255bbf5f4ee997fd6de62cb50fc9b5dd697
TemplateView.get_context_data()'s kwargs returns SimpleLazyObjects that causes a crash when filtering. Description Example Code that works in 3.0, but not in 3.1: class OfferView(TemplateView): template_name = "offers/offer.html" def get_context_data(self, **kwargs): offer_slug = kwargs.get("offer_slug", "") of...
Thanks for the report. get_object_or_404() and QuerySet.filter() with SimpleLazyObject throw the same exception in Django 2.2 or 3.0. TemplateView.get_context_data()'s kwargs returns SimpleLazyObjects in Django 3.1 which causes a crash. Passing URL kwargs into context is deprecated (see #19878) but should still work in...
2020-08-12T11:20:33Z
<patch> 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 @@ -11,7 +11,7 @@ from django.urls import reverse from django.utils.decorators import classonlymethod from django.utils.deprecation import RemovedInDjango40Warning -f...
diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py --- a/tests/generic_views/test_base.py +++ b/tests/generic_views/test_base.py @@ -3,7 +3,8 @@ from django.core.exceptions import ImproperlyConfigured from django.http import HttpResponse from django.test import ( - RequestFactory, Si...
3.2
["test_template_params_filtering (generic_views.test_base.DeprecationTests)"]
["test_get_context_data_super (generic_views.test_base.GetContextDataTest)", "test_object_at_custom_name_in_context_data (generic_views.test_base.GetContextDataTest)", "test_object_in_get_context_data (generic_views.test_base.GetContextDataTest)", "test_overwrite_queryset (generic_views.test_base.UseMultipleObjectMixin...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13315
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> limit_choices_to on a ForeignKey can render duplicate options in formfield Description If you pass a Q object as limit_choices_to on a ForeignKey field involving a join, you may end up with duplicate options ...
django/django
36bc47069ce071e80c8129500de3b8664d2058a7
limit_choices_to on a ForeignKey can render duplicate options in formfield Description If you pass a Q object as limit_choices_to on a ForeignKey field involving a join, you may end up with duplicate options in your form. See regressiontest in patch for a clear view on the problem.
Replying to SmileyChris: I've updated the patch to resolve the conflicts I've had since you flagged this one as "Ready for checkin". No real change. update resolving conflict Is there something I can do to get this checked in? I re-read the ​Triage docs. As far as I can see "A developer checks in the fix" is the only s...
2020-08-17T04:24:39Z
<patch> diff --git a/django/forms/models.py b/django/forms/models.py --- a/django/forms/models.py +++ b/django/forms/models.py @@ -97,10 +97,18 @@ def model_to_dict(instance, fields=None, exclude=None): def apply_limit_choices_to_to_formfield(formfield): """Apply limit_choices_to to the formfield's queryset if ...
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -411,9 +411,14 @@ class StumpJoke(models.Model): Character, models.CASCADE, limit_choices_to=today_callable_dict, - related_name="+", + r...
3.2
["test_limit_choices_to_no_duplicates (model_forms.tests.LimitChoicesToTests)"]
["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "test_bad_callback (model_forms.tests.FormFieldCallbackTests)", "Regression for #13095: Using base forms with widgets defined in Meta should not raise errors.", "A custom formfield_callback is used if provided", "Regression for #15315: mod...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13343
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> FileField with a callable storage does not deconstruct properly Description A FileField with a callable storage parameter should not actually evaluate the callable when it is being deconstructed. The document...
django/django
ece18207cbb64dd89014e279ac636a6c9829828e
FileField with a callable storage does not deconstruct properly Description A FileField with a callable storage parameter should not actually evaluate the callable when it is being deconstructed. The documentation for a FileField with a callable storage parameter, states: You can use a callable as the storage paramet...
2020-08-24T19:29:12Z
<patch> 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 @@ -229,6 +229,8 @@ def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **k self.storage = storage or default_storage...
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -29,7 +29,9 @@ from django.urls import NoReverseMatch, reverse_lazy from django.utils import timezone -from .models import Storage, temp_storage, temp_storage_location +from ...
3.2
["test_deconstruction (file_storage.tests.FieldCallableFileStorageTests)"]
["test_get_filesystem_storage (file_storage.tests.GetStorageClassTests)", "test_get_invalid_storage_module (file_storage.tests.GetStorageClassTests)", "test_get_nonexistent_storage_class (file_storage.tests.GetStorageClassTests)", "test_get_nonexistent_storage_module (file_storage.tests.GetStorageClassTests)", "test_ca...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13344
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Coroutine passed to the first middleware's process_response() instead of HttpResponse. Description Like the title says, using ASGI (+ uvicorn in my case), the first middleware (according to the list in settin...
django/django
e39e727ded673e74016b5d3658d23cbe20234d11
Coroutine passed to the first middleware's process_response() instead of HttpResponse. Description Like the title says, using ASGI (+ uvicorn in my case), the first middleware (according to the list in settings.py) receives a coroutine as its response parameter, while all other middlewares down the line receive a dja...
Tentatively accepted for investigation. It's not about the first middleware because if you have only one it gets HttpResponse, but if you have at least two then then the first in a chain gets coroutine. Andrew, Can you take a look? I think it's a bug in SecurityMiddleware : its __init__ does not call super().__init__()...
2020-08-24T20:50:35Z
<patch> diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py --- a/django/contrib/sessions/middleware.py +++ b/django/contrib/sessions/middleware.py @@ -13,9 +13,7 @@ class SessionMiddleware(MiddlewareMixin): # RemovedInDjango40Warning: when the deprecation ends, replace with:...
diff --git a/tests/cache/tests.py b/tests/cache/tests.py --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -2083,6 +2083,7 @@ def test_constructor(self): self.assertEqual(middleware.cache_timeout, 30) self.assertEqual(middleware.key_prefix, 'middlewareprefix') self.assertEqual(middlewa...
3.2
["test_coroutine (deprecation.test_middleware_mixin.MiddlewareMixinTests)", "test_deprecation (deprecation.test_middleware_mixin.MiddlewareMixinTests)"]
["Nonexistent cache keys return as None/default.", "set_many() returns an empty list when all keys are inserted.", "test_createcachetable_observes_database_router (cache.tests.CreateCacheTableForDBCacheTests)", "test_per_thread (cache.tests.CacheHandlerTest)", "test_same_instance (cache.tests.CacheHandlerTest)", "If No...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13346
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> On MySQL, Oracle, and SQLite, __in lookup doesn't work on key transforms. Description I am currently rewriting our app where we will start using models.JSONField instead of django_mysql.models.JSONField. I no...
django/django
9c92924cd5d164701e2514e1c2d6574126bd7cc2
On MySQL, Oracle, and SQLite, __in lookup doesn't work on key transforms. Description I am currently rewriting our app where we will start using models.JSONField instead of django_mysql.models.JSONField. I noticed that the __in operator is not reacting the same way is it does on other fields. first_filter = {‘our_fie...
Thanks for this ticket, however I cannot reproduce this issue. I tried with the following test and it works for me (also on MySQL): diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index a7648711ac..97d79e5bee 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fi...
2020-08-25T06:25:31Z
<patch> diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py --- a/django/db/models/fields/json.py +++ b/django/db/models/fields/json.py @@ -378,6 +378,30 @@ def as_sqlite(self, compiler, connection): return super().as_sql(compiler, connection) +class KeyTransformIn(lookups.In): +...
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -627,6 +627,25 @@ def test_key_iexact(self): self.assertIs(NullableJSONModel.objects.filter(value__foo__iexact='BaR').exists(), True)...
3.2
["test_key_in (model_fields.test_jsonfield.TestQuerying)", "test_key_iregex (model_fields.test_jsonfield.TestQuerying)"]
["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_custom_encoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_decoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_encoder (model_fields...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13363
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Add support for tzinfo parameter to TruncDate() and TruncTime(). Description (last modified by Joe Jackson) Description TruncDate inherits from TruncBase, which includes the TimeZone mixin. This should ...
django/django
76e0151ea0e0f56dca66cee846a78b89346d2c4c
Add support for tzinfo parameter to TruncDate() and TruncTime(). Description (last modified by Joe Jackson) Description TruncDate inherits from TruncBase, which includes the TimeZone mixin. This should allow a developer to pass in a tzinfo object to be used when converting TruncDate, but it actually uses the re...
Please check https://code.djangoproject.com/ticket/31640 Is it related to your issue? Replying to Serhii Romanov: Please check https://code.djangoproject.com/ticket/31640 Is it related to your issue? It is related, but not exactly my issue. That patch updates the TruncBase as_sql method, and world work. But the TruncDa...
2020-08-29T18:59:41Z
<patch> diff --git a/django/db/models/functions/datetime.py b/django/db/models/functions/datetime.py --- a/django/db/models/functions/datetime.py +++ b/django/db/models/functions/datetime.py @@ -292,7 +292,7 @@ class TruncDate(TruncBase): def as_sql(self, compiler, connection): # Cast to date rather than ...
diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py --- a/tests/db_functions/datetime/test_extract_trunc.py +++ b/tests/db_functions/datetime/test_extract_trunc.py @@ -1124,14 +1124,24 @@ def test_trunc_timezone_applied_before_truncation(self): mod...
3.2
["test_trunc_timezone_applied_before_truncation (db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests)"]
["test_extract_day_func (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_unsupported_lookups (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_without_native_duration_field (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extra...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13401
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Abstract model field should not be equal across models Description Consider the following models: class A(models.Model): class Meta: abstract = True myfield = IntegerField() class B(A): pass class C(A): ...
django/django
453967477e3ddae704cd739eac2449c0e13d464c
Abstract model field should not be equal across models Description Consider the following models: class A(models.Model): class Meta: abstract = True myfield = IntegerField() class B(A): pass class C(A): pass If I pull the fields of B and C into a shared set, one will be de-duplicated away, because they compare ...
2020-09-09T11:19:00Z
<patch> diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -516,17 +516,37 @@ def clone(self): def __eq__(self, other): # Needed for @total_ordering if isinstance(other, Fiel...
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -102,6 +102,36 @@ def test_deconstruct_nested_field(self): name, path, args, kwargs = Nested.Field().deconstruct() self.assertEqual(path, 'model_fields.tests.Ne...
3.2
["Field instances from abstract models are not equal."]
["test_blank_in_choices (model_fields.tests.GetChoicesTests)", "test_blank_in_grouped_choices (model_fields.tests.GetChoicesTests)", "test_empty_choices (model_fields.tests.GetChoicesTests)", "test_lazy_strings_not_evaluated (model_fields.tests.GetChoicesTests)", "test_get_choices (model_fields.tests.GetChoicesLimitCho...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13406
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Queryset with values()/values_list() crashes when recreated from a pickled query. Description I am pickling query objects (queryset.query) for later re-evaluation as per ​https://docs.djangoproject.com/en/2.2...
django/django
84609b3205905097d7d3038d32e6101f012c0619
Queryset with values()/values_list() crashes when recreated from a pickled query. Description I am pickling query objects (queryset.query) for later re-evaluation as per ​https://docs.djangoproject.com/en/2.2/ref/models/querysets/#pickling-querysets. However, when I tried to rerun a query that combines values and ann...
It seems that I have found the culprit. The queryset has an attribute _iterable_class, which in case of a .objects.all() type of query is ModelIterable, but when .values() is used, it should be ValuesIterable. Unfortunately, this is an attribute of the queryset, not of the query and thus it does not get pickled and unp...
2020-09-10T12:38:11Z
<patch> 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 @@ -210,6 +210,8 @@ def query(self): @query.setter def query(self, value): + if value.values_select: + self._iterable_class = ValuesIterable s...
diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -11,7 +11,7 @@ class PickleabilityTestCase(TestCase): @classmethod def setUpTestData(cls): - Happening.objects.create() # make sure the defaults ar...
3.2
["test_annotation_values (queryset_pickle.tests.PickleabilityTestCase)", "test_annotation_values_list (queryset_pickle.tests.PickleabilityTestCase)", "test_annotation_with_callable_default (queryset_pickle.tests.PickleabilityTestCase)"]
["test_in_lookup_query_evaluation (queryset_pickle.tests.InLookupTests)", "test_in_lookup_queryset_evaluation (queryset_pickle.tests.InLookupTests)", "test_datetime_callable_default_all (queryset_pickle.tests.PickleabilityTestCase)", "test_datetime_callable_default_filter (queryset_pickle.tests.PickleabilityTestCase)",...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13410
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Bug in posix implementation of django/core/files/locks.py Description The posix version of locks (the version which supports import fcntl) has a bug. The code attempts to return True to indicate success or fa...
django/django
580a4341cb0b4cbfc215a70afc004875a7e815f4
Bug in posix implementation of django/core/files/locks.py Description The posix version of locks (the version which supports import fcntl) has a bug. The code attempts to return True to indicate success or failure acquiring a lock, but instead it always returns False. The reason is that cpython fcntl module returns N...
Thanks for the ticket. Would you like to prepare a pull request? (tests are also required).
2020-09-11T09:58:41Z
<patch> diff --git a/django/core/files/locks.py b/django/core/files/locks.py --- a/django/core/files/locks.py +++ b/django/core/files/locks.py @@ -107,9 +107,12 @@ def unlock(f): return True else: def lock(f, flags): - ret = fcntl.flock(_fd(f), flags) - return ret == 0 +...
diff --git a/tests/files/tests.py b/tests/files/tests.py --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -8,7 +8,7 @@ from pathlib import Path from unittest import mock -from django.core.files import File +from django.core.files import File, locks from django.core.files.base import ContentFile from djang...
3.2
["test_exclusive_lock (files.tests.FileTests)", "test_shared_lock (files.tests.FileTests)"]
["test_open_resets_file_to_start_and_returns_context_manager (files.tests.InMemoryUploadedFileTests)", "test_content_file_custom_name (files.tests.ContentFileTestCase)", "test_content_file_default_name (files.tests.ContentFileTestCase)", "test_content_file_input_type (files.tests.ContentFileTestCase)", "test_open_reset...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13417
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> QuerySet.ordered property is incorrect for GROUP BY queries on models with Meta.ordering. Description Using the annotate function on a queryset doesn't keep the default ordering set in model's meta class. A p...
django/django
71ae1ab0123582cc5bfe0f7d5f4cc19a9412f396
QuerySet.ordered property is incorrect for GROUP BY queries on models with Meta.ordering. Description Using the annotate function on a queryset doesn't keep the default ordering set in model's meta class. A property should say whether the queryset will be ordered or not. I wanted to use the qs.ordered property for th...
Thanks for this report, however QuerySet.ordered works for me, see ​tests. Replying to felixxm: Thanks for this report, however QuerySet.ordered works for me, see ​tests. Thanks for your answer but I've just checked again as it is in my example and ordered still returns True if an annotation is applied. As said earlier...
2020-09-14T07:49:15Z
<patch> 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 @@ -1224,7 +1224,12 @@ def ordered(self): return True if self.query.extra_order_by or self.query.order_by: return True - elif self.query.de...
diff --git a/tests/queries/tests.py b/tests/queries/tests.py --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2084,6 +2084,16 @@ def test_annotated_ordering(self): self.assertIs(qs.ordered, False) self.assertIs(qs.order_by('num_notes').ordered, True) + def test_annotated_default_orde...
3.2
["test_annotated_default_ordering (queries.tests.QuerysetOrderedTests)", "test_annotated_values_default_ordering (queries.tests.QuerysetOrderedTests)"]
["test_no_extra_params (queries.tests.DefaultValuesInsertTest)", "test_ticket14729 (queries.tests.RawQueriesTests)", "test_exists (queries.tests.ExistsSql)", "test_ticket_18414 (queries.tests.ExistsSql)", "test_ticket_24278 (queries.tests.TestTicket24279)", "test_ticket7371 (queries.tests.CustomPkTests)", "test_ticket_...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13449
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Lag() with DecimalField crashes on SQLite. Description On Django 3.0.7 with a SQLite database using the following model: from django.db import models class LagTest(models.Model): modified = models.DateField(...
django/django
2a55431a5678af52f669ffe7dff3dd0bd21727f8
Lag() with DecimalField crashes on SQLite. Description On Django 3.0.7 with a SQLite database using the following model: from django.db import models class LagTest(models.Model): modified = models.DateField() data = models.FloatField() amount = models.DecimalField(decimal_places=4, max_digits=7) and the following ...
Thanks for this report. I can also confirm that it works properly with FloatField(). Reproduced at 27c09043da52ca1f02605bf28600bfd5ace95ae4. Likely an issue due to SQLiteNumericMixin ​https://github.com/django/django/blob/27c09043da52ca1f02605bf28600bfd5ace95ae4/django/db/models/expressions.py#L16-L28 We could make Win...
2020-09-22T13:04:03Z
<patch> 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 @@ -1253,7 +1253,7 @@ def desc(self): self.descending = True -class Window(Expression): +class Window(SQLiteNumericMixin, Expression): temp...
diff --git a/tests/expressions_window/models.py b/tests/expressions_window/models.py --- a/tests/expressions_window/models.py +++ b/tests/expressions_window/models.py @@ -12,3 +12,4 @@ class Employee(models.Model): hire_date = models.DateField(blank=False, null=False) age = models.IntegerField(blank=False, nu...
3.2
["test_lag_decimalfield (expressions_window.tests.WindowFunctionTests)"]
["test_conditional_annotation (expressions_window.tests.NonQueryWindowTests)", "test_empty_group_by_cols (expressions_window.tests.NonQueryWindowTests)", "test_frame_empty_group_by_cols (expressions_window.tests.NonQueryWindowTests)", "test_frame_window_frame_notimplemented (expressions_window.tests.NonQueryWindowTests...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13512
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Admin doesn't display properly unicode chars in JSONFields. Description (last modified by ZhaoQi99) >>> import json >>> print json.dumps('中国') "\u4e2d\u56fd" json.dumps use ASCII encoding by default whe...
django/django
b79088306513d5ed76d31ac40ab3c15f858946ea
Admin doesn't display properly unicode chars in JSONFields. Description (last modified by ZhaoQi99) >>> import json >>> print json.dumps('中国') "\u4e2d\u56fd" json.dumps use ASCII encoding by default when serializing Chinese. So when we edit a JsonField which contains Chinese character in Django admin,it will ap...
As far as I'm aware, we cannot use ensure_ascii=False by default because it requires utf8mb4 encoding on MySQL, see #18392. It looks that you can use a custom encoder/decoder to make it works without changes in Django. Replying to felixxm: As far as I'm aware, we cannot use ensure_ascii=False by default because it requ...
2020-10-08T13:52:57Z
<patch> diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -1,5 +1,6 @@ import datetime import decimal +import json from collections import defaultdict from django.core.exceptions import FieldDoesNotExist @@ -400,7 ...
diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py --- a/tests/admin_utils/tests.py +++ b/tests/admin_utils/tests.py @@ -186,6 +186,7 @@ def test_json_display_for_field(self): ({'a': {'b': 'c'}}, '{"a": {"b": "c"}}'), (['a', 'b'], '["a", "b"]'), ('a', '"a"'), + ...
3.2
["test_prepare_value (forms_tests.field_tests.test_jsonfield.JSONFieldTest)", "test_json_display_for_field (admin_utils.tests.UtilsTests)", "test_label_for_field (admin_utils.tests.UtilsTests)"]
["test_cyclic (admin_utils.tests.NestedObjectsTests)", "test_non_added_parent (admin_utils.tests.NestedObjectsTests)", "test_on_delete_do_nothing (admin_utils.tests.NestedObjectsTests)", "test_queries (admin_utils.tests.NestedObjectsTests)", "test_relation_on_abstract (admin_utils.tests.NestedObjectsTests)", "test_sibl...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13513
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> debug error view doesn't respect exc.__suppress_context__ (PEP 415) Description Consider the following view that raises an exception: class TestView(View): def get(self, request, *args, **kwargs): try: ...
django/django
6599608c4d0befdcb820ddccce55f183f247ae4f
debug error view doesn't respect exc.__suppress_context__ (PEP 415) Description Consider the following view that raises an exception: class TestView(View): def get(self, request, *args, **kwargs): try: raise RuntimeError('my error') except Exception as exc: raise ValueError('my new error') from None Even t...
Here is a related (but different) issue about the traceback shown by the debug error view ("debug error view shows no traceback if exc.traceback is None for innermost exception"): https://code.djangoproject.com/ticket/31672 Thanks Chris. Would you like to prepare a patch? PR: ​https://github.com/django/django/pull/1317...
2020-10-08T14:07:33Z
<patch> diff --git a/django/views/debug.py b/django/views/debug.py --- a/django/views/debug.py +++ b/django/views/debug.py @@ -394,19 +394,19 @@ def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, mod return None, [], None, [] return lower_bound, pre_context, context_line,...
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py --- a/tests/view_tests/tests/test_debug.py +++ b/tests/view_tests/tests/test_debug.py @@ -467,6 +467,34 @@ def test_suppressed_context(self): self.assertIn('<p>Request data not supplied</p>', html) self.assertNotI...
3.2
["test_innermost_exception_without_traceback (view_tests.tests.test_debug.ExceptionReporterTests)"]
["test_sensitive_post_parameters_not_called (view_tests.tests.test_debug.DecoratorsTests)", "test_sensitive_variables_not_called (view_tests.tests.test_debug.DecoratorsTests)", "test_repr (view_tests.tests.test_debug.CallableSettingWrapperTests)", "test_cleansed_substitute_override (view_tests.tests.test_debug.CustomEx...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13516
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> flush() on self.stdout/stderr management commands doesn't work. Description flush() is notably called during migrate command; it doesn't work, and a long migration effectively prints to stderr no relevant inf...
django/django
b7da588e883e12b8ac3bb8a486e654e30fc1c6c8
flush() on self.stdout/stderr management commands doesn't work. Description flush() is notably called during migrate command; it doesn't work, and a long migration effectively prints to stderr no relevant information up until the end: Operations to perform: Apply all migrations: myapp Running migrations: Then nothin...
2020-10-08T19:00:01Z
<patch> 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 @@ -140,6 +140,10 @@ def __init__(self, out, ending='\n'): def __getattr__(self, name): return getattr(self._out, name) + def flush(self): + ...
diff --git a/tests/user_commands/management/commands/outputwrapper.py b/tests/user_commands/management/commands/outputwrapper.py new file mode 100644 --- /dev/null +++ b/tests/user_commands/management/commands/outputwrapper.py @@ -0,0 +1,8 @@ +from django.core.management.base import BaseCommand + + +class Command(BaseC...
3.2
["test_outputwrapper_flush (user_commands.tests.CommandTests)"]
["test_requires_system_checks_false (user_commands.tests.DeprecationTests)", "test_requires_system_checks_true (user_commands.tests.DeprecationTests)", "test_requires_system_checks_warning (user_commands.tests.DeprecationTests)", "test_get_random_secret_key (user_commands.tests.UtilsTests)", "test_is_ignored_path_false...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13551
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Changing user's email could invalidate password reset tokens Description Sequence: Have account with email address foo@… Password reset request for that email (unused) foo@… account changes their email addres...
django/django
7f9e4524d6b23424cf44fbe1bf1f4e70f6bb066e
Changing user's email could invalidate password reset tokens Description Sequence: Have account with email address foo@… Password reset request for that email (unused) foo@… account changes their email address Password reset email is used The password reset email's token should be rejected at that point, but in fact ...
2020-10-17T17:22:01Z
<patch> diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py --- a/django/contrib/auth/tokens.py +++ b/django/contrib/auth/tokens.py @@ -78,9 +78,9 @@ def _make_token_with_timestamp(self, user, timestamp, legacy=False): def _make_hash_value(self, user, timestamp): """ - Hash...
diff --git a/tests/auth_tests/models/__init__.py b/tests/auth_tests/models/__init__.py --- a/tests/auth_tests/models/__init__.py +++ b/tests/auth_tests/models/__init__.py @@ -8,6 +8,7 @@ from .no_password import NoPasswordUser from .proxy import Proxy, UserProxy from .uuid_pk import UUIDUser +from .with_custom_email...
3.2
["Updating the user email address invalidates the token.", "test_token_with_different_secret (auth_tests.test_tokens.TokenGeneratorTest)"]
["test_str (auth_tests.test_models.GroupTests)", "test_group_natural_key (auth_tests.test_models.NaturalKeysTestCase)", "test_user_natural_key (auth_tests.test_models.NaturalKeysTestCase)", "test_check_password (auth_tests.test_models.AnonymousUserTests)", "test_delete (auth_tests.test_models.AnonymousUserTests)", "tes...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13568
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Skip auth.E003 system check for USERNAME_FIELD with total UniqueConstraints. Description Defining a user model like this: class User(AbstractBaseUser): username = models.CharField(max_length=30) USERNAME_FI...
django/django
ede9fac75807fe5810df66280a60e7068cc97e4a
Skip auth.E003 system check for USERNAME_FIELD with total UniqueConstraints. Description Defining a user model like this: class User(AbstractBaseUser): username = models.CharField(max_length=30) USERNAME_FIELD = "username" class Meta: constraints = [UniqueConstraint(fields=["username"], name="user_username_unq")...
2020-10-19T15:20:08Z
<patch> diff --git a/django/contrib/auth/checks.py b/django/contrib/auth/checks.py --- a/django/contrib/auth/checks.py +++ b/django/contrib/auth/checks.py @@ -52,7 +52,10 @@ def check_user_model(app_configs=None, **kwargs): ) # Check that the username field is unique - if not cls._meta.get_field(cls....
diff --git a/tests/auth_tests/test_checks.py b/tests/auth_tests/test_checks.py --- a/tests/auth_tests/test_checks.py +++ b/tests/auth_tests/test_checks.py @@ -4,6 +4,7 @@ from django.contrib.auth.models import AbstractBaseUser from django.core import checks from django.db import models +from django.db.models import ...
3.2
["test_username_unique_with_model_constraint (auth_tests.test_checks.UserModelChecksTests)"]
["test_clashing_custom_permissions (auth_tests.test_checks.ModelsPermissionsChecksTests)", "test_clashing_default_permissions (auth_tests.test_checks.ModelsPermissionsChecksTests)", "test_custom_permission_codename_max_length (auth_tests.test_checks.ModelsPermissionsChecksTests)", "test_custom_permission_name_max_lengt...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13569
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> order_by('?') unexpectedly breaking queryset aggregation Description Steps to reproduce: class Thing(models.Model): pass class Related(models.Model): models.ForeignKey(Thing) With data t = Thing.objects.cre...
django/django
257f8495d6c93e30ab0f52af4c488d7344bcf112
order_by('?') unexpectedly breaking queryset aggregation Description Steps to reproduce: class Thing(models.Model): pass class Related(models.Model): models.ForeignKey(Thing) With data t = Thing.objects.create() rs = [Related.objects.create(thing=t) for _ in range(2)] The following query works as expected. The aggr...
Patch to SQLCompiler.get_group_by that excluds Random expressions ​PR I wonder what would happen if we skipped all expressions that have no cols as source expressions (plus, we need to include any raw sql). I wonder what would happen if we skipped all expressions that have no cols as source expressions (plus, we need t...
2020-10-19T21:20:55Z
<patch> diff --git a/django/db/models/functions/math.py b/django/db/models/functions/math.py --- a/django/db/models/functions/math.py +++ b/django/db/models/functions/math.py @@ -154,6 +154,9 @@ def as_oracle(self, compiler, connection, **extra_context): def as_sqlite(self, compiler, connection, **extra_context): ...
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1315,3 +1315,18 @@ def test_aggregation_subquery_annotation_related_field(self): # with self.assertNumQueries(1) as ctx: # self.assertSequenceEqual(books_qs, [...
3.2
["Random() is not included in the GROUP BY when used for ordering."]
["test_add_implementation (aggregation.tests.AggregateTestCase)", "test_aggregate_alias (aggregation.tests.AggregateTestCase)", "test_aggregate_annotation (aggregation.tests.AggregateTestCase)", "test_aggregate_in_order_by (aggregation.tests.AggregateTestCase)", "test_aggregate_multi_join (aggregation.tests.AggregateTe...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13590
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Upgrading 2.2>3.0 causes named tuples used as arguments to __range to error. Description I noticed this while upgrading a project from 2.2 to 3.0. This project passes named 2-tuples as arguments to range quer...
django/django
755dbf39fcdc491fe9b588358303e259c7750be4
Upgrading 2.2>3.0 causes named tuples used as arguments to __range to error. Description I noticed this while upgrading a project from 2.2 to 3.0. This project passes named 2-tuples as arguments to range queryset filters. This works fine on 2.2. On 3.0 it causes the following error: TypeError: __new__() missing 1 req...
2020-10-23T09:34:55Z
<patch> 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 @@ -1077,10 +1077,14 @@ def resolve_lookup_value(self, value, can_reuse, allow_joins): elif isinstance(value, (list, tuple)): # The items of th...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -2,6 +2,7 @@ import pickle import unittest import uuid +from collections import namedtuple from copy import deepcopy from decimal import Decimal from unittest import mock @@ -8...
3.2
["test_range_lookup_namedtuple (expressions.tests.IterableLookupInnerExpressionsTests)"]
["test_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_non_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_e...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13658
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ManagementUtility instantiates CommandParser without passing already-computed prog argument Description ManagementUtility ​goes to the trouble to parse the program name from the argv it's passed rather than f...
django/django
0773837e15bb632afffb6848a58c59a791008fa1
ManagementUtility instantiates CommandParser without passing already-computed prog argument Description ManagementUtility ​goes to the trouble to parse the program name from the argv it's passed rather than from sys.argv: def __init__(self, argv=None): self.argv = argv or sys.argv[:] self.prog_name = os.path.ba...
Tentatively accepted, looks valid but I was not able to reproduce and invalid message (even with mocking sys.argv), so a regression test is crucial.
2020-11-09T20:50:28Z
<patch> diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -344,7 +344,12 @@ def execute(self): # Preprocess options to extract --settings and --pythonpath. # These options could affe...
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 @@ -17,7 +17,7 @@ from django import conf, get_version from django.conf import settings from django.core.management import ( - BaseCommand, CommandError, call_command, col...
3.2
["test_program_name_from_argv (admin_scripts.tests.ExecuteFromCommandLine)"]
["test_params_to_runserver (admin_scripts.tests.ManageTestserver)", "test_testserver_handle_params (admin_scripts.tests.ManageTestserver)", "test_no_database (admin_scripts.tests.ManageRunserver)", "test_readonly_database (admin_scripts.tests.ManageRunserver)", "test_runner_addrport_ipv6 (admin_scripts.tests.ManageRuns...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13670
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> dateformat.y() doesn't support years < 1000. Description (last modified by Sam) When using the the dateformat of django with a date before 999 (or 99 and 9 for similar matters) and the format character ...
django/django
c448e614c60cc97c6194c62052363f4f501e0953
dateformat.y() doesn't support years < 1000. Description (last modified by Sam) When using the the dateformat of django with a date before 999 (or 99 and 9 for similar matters) and the format character "y" no leading zero will be printed. This is not consistent with the way the python datetime module and PHP ha...
2020-11-12T11:45:51Z
<patch> diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -325,8 +325,8 @@ def W(self): return self.data.isocalendar()[1] def y(self): - "Year, 2 digits; e.g. '99'" - return str(self.data.year)[2:] + ...
diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py --- a/tests/utils_tests/test_dateformat.py +++ b/tests/utils_tests/test_dateformat.py @@ -165,3 +165,16 @@ def test_r_format_with_non_en_locale(self): dateformat.format(dt, 'r'), 'Sun, 08 Jul 1979 ...
3.2
["test_year_before_1000 (utils_tests.test_dateformat.DateFormatTests)"]
["test_am_pm (utils_tests.test_dateformat.DateFormatTests)", "test_date (utils_tests.test_dateformat.DateFormatTests)", "test_date_formats (utils_tests.test_dateformat.DateFormatTests)", "test_dateformat (utils_tests.test_dateformat.DateFormatTests)", "test_datetime_with_local_tzinfo (utils_tests.test_dateformat.DateFo...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13741
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Set disabled prop on ReadOnlyPasswordHashField Description Currently the django.contrib.auth.forms.UserChangeForm defines a clean_password method that returns the initial password value to prevent (accidental...
django/django
d746f28949c009251a8741ba03d156964050717f
Set disabled prop on ReadOnlyPasswordHashField Description Currently the django.contrib.auth.forms.UserChangeForm defines a clean_password method that returns the initial password value to prevent (accidental) changes to the password value. It is also documented that custom forms for the User model need to define thi...
Sounds good. Would you like to provide a patch? Replying to Mariusz Felisiak: Sounds good. Would you like to provide a patch? I don't have the time to do a proper patch (with doc changes and additional tests). But I marked it as "Easy pickings" to entice others that are trying to get into contribution to Django ;-) I'd...
2020-12-02T10:52:52Z
<patch> 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 @@ -56,16 +56,9 @@ class ReadOnlyPasswordHashField(forms.Field): def __init__(self, *args, **kwargs): kwargs.setdefault("required", False) + kwarg...
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 @@ -1022,6 +1022,7 @@ def test_render(self): def test_readonly_field_has_changed(self): field = ReadOnlyPasswordHashField() + self.assertIs(field....
3.2
["test_readonly_field_has_changed (auth_tests.test_forms.ReadOnlyPasswordHashTest)"]
["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...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13786
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> squashmigrations does not unset model options when optimizing CreateModel and AlterModelOptions Description When an operation resembling AlterModelOptions(name="test_model", options={}) is squashed into the c...
django/django
bb64b99b78a579cb2f6178011a4cf9366e634438
squashmigrations does not unset model options when optimizing CreateModel and AlterModelOptions Description When an operation resembling AlterModelOptions(name="test_model", options={}) is squashed into the corresponding CreateModel operation, model options are not cleared on the resulting new CreateModel operation o...
Makes sense, I guess we should take AlterModelOptions.ALTER_OPTION_KEYS in consideration here like AlterModelOptions.state_forwards does ​https://github.com/django/django/blob/991dce4fc5b656e04af08a595181bd576f2bd857/django/db/migrations/operations/models.py#L675-L677
2020-12-17T21:10:10Z
<patch> 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 @@ -137,11 +137,15 @@ def reduce(self, operation, app_label): ), ] elif isinst...
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 @@ -119,6 +119,42 @@ def test_create_alter_model_options(self): ] ) + def test_create_model_and_remove_model_options(self): + ...
3.2
["test_create_model_and_remove_model_options (migrations.test_optimizer.OptimizerTests)"]
["test_add_field_alter_field (migrations.test_optimizer.OptimizerTests)", "test_add_field_delete_field (migrations.test_optimizer.OptimizerTests)", "test_add_field_rename_field (migrations.test_optimizer.OptimizerTests)", "test_alter_alter_index_model (migrations.test_optimizer.OptimizerTests)", "test_alter_alter_owrt_...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13794
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> add filter is unable to concatenate strings with lazy string Description If you try to concatenate a string with a lazy string with the add template filter, the result is always the empty string because the a...
django/django
fe886eee36be8022f34cfe59aa61ff1c21fe01d9
add filter is unable to concatenate strings with lazy string Description If you try to concatenate a string with a lazy string with the add template filter, the result is always the empty string because the add filter generates an exception (TypeError: can only concatenate str (not "__proxy__") to str).
Tests. Thanks. I attached a test.
2020-12-19T20:09:34Z
<patch> diff --git a/django/utils/functional.py b/django/utils/functional.py --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -176,6 +176,12 @@ def __mod__(self, rhs): return str(self) % rhs return self.__cast() % rhs + def __add__(self, other): + re...
diff --git a/tests/template_tests/filter_tests/test_add.py b/tests/template_tests/filter_tests/test_add.py --- a/tests/template_tests/filter_tests/test_add.py +++ b/tests/template_tests/filter_tests/test_add.py @@ -2,6 +2,7 @@ from django.template.defaultfilters import add from django.test import SimpleTestCase +fr...
3.2
["test_lazy_add (utils_tests.test_functional.FunctionalTests)", "test_add08 (template_tests.filter_tests.test_add.AddTests)", "test_add09 (template_tests.filter_tests.test_add.AddTests)"]
["test_add (template_tests.filter_tests.test_add.FunctionTests)", "cached_property caches its value and behaves like a property.", "test_cached_property_auto_name (utils_tests.test_functional.FunctionalTests)", "Disallow this case because the decorated function wouldn't be cached.", "test_cached_property_reuse_same_nam...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13807
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> loaddata crashes on SQLite when table names are SQL keywords. Description Steps to reproduce: Create a Model called Order. (order is a SQL reserved word) Create fixtures for the model Use manage.py loaddata t...
django/django
89fc144dedc737a79929231438f035b1d4a993c9
loaddata crashes on SQLite when table names are SQL keywords. Description Steps to reproduce: Create a Model called Order. (order is a SQL reserved word) Create fixtures for the model Use manage.py loaddata to load the fixture. Notice that it fails with the following error. This is because the table name order is not...
Thanks for the report, I was able to reproduce this issue with db_table = 'order'. Reproduced at 966b5b49b6521483f1c90b4499c4c80e80136de3. Simply wrapping table_name in connection.ops.quote_name should address the issue for anyone interested in picking the issue up. a little guidance needed as this is my first ticket. ...
2020-12-23T21:09:32Z
<patch> diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -327,19 +327,24 @@ def check_constraints(self, table_names=None): violations = cursor.execute('PRAGMA foreign_key_check')...
diff --git a/tests/backends/models.py b/tests/backends/models.py --- a/tests/backends/models.py +++ b/tests/backends/models.py @@ -140,3 +140,11 @@ class Author(models.Model): class Book(models.Model): author = models.ForeignKey(Author, models.CASCADE, to_field='name') + + +class SQLKeywordsModel(models.Model):...
3.2
["test_check_constraints_sql_keywords (backends.tests.FkConstraintsTests)"]
["Sequence names are correct when resetting generic relations (Ref #13941)", "test_parameter_escaping (backends.tests.EscapingChecks)", "test_paramless_no_escaping (backends.tests.EscapingChecks)", "An executemany call with too many/not enough parameters will raise an exception (Refs #12612)", "test_parameter_escaping ...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13809
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Add --skip-checks option to the runserver command. Description Rationale: It would be consistent with other management commands performing system checks It would help people like me who would rather have chec...
django/django
bef6f7584280f1cc80e5e2d80b7ad073a93d26ec
Add --skip-checks option to the runserver command. Description Rationale: It would be consistent with other management commands performing system checks It would help people like me who would rather have checks enabled exclusively in CI/CD than wait 15-20 seconds for each project reload during development Related Sta...
Sounds reasonable. ​PR
2020-12-24T15:31:35Z
<patch> 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 @@ -51,6 +51,10 @@ def add_arguments(self, parser): '--noreload', action='store_false', dest...
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 @@ -1313,6 +1313,29 @@ def test_readonly_database(self): # You have # ... self.assertIn('unapplied migration(s)', self.output.getvalue()) + @mock.patch('d...
4.0
["test_skip_checks (admin_scripts.tests.ManageRunserver)"]
["test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_ex...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-13810
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> MiddlewareNotUsed leaves undesired side effects when loading middleware in ASGI context Description I experienced strange issues when working with ​ASGI , ​django-debug-toolbar and my own small middleware. It...
django/django
429d089d0a8fbd400e0c010708df4f0d16218970
MiddlewareNotUsed leaves undesired side effects when loading middleware in ASGI context Description I experienced strange issues when working with ​ASGI , ​django-debug-toolbar and my own small middleware. It was hard problem to debug, I uploaded an example project here: ​https://github.com/hbielenia/asgi-djangotoolb...
Many thanks for the detailed report.
2020-12-26T12:31:18Z
<patch> diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -51,11 +51,11 @@ def load_middleware(self, is_async=False): middleware_is_async = middleware_can_async try: # Adapt han...
diff --git a/tests/middleware_exceptions/tests.py b/tests/middleware_exceptions/tests.py --- a/tests/middleware_exceptions/tests.py +++ b/tests/middleware_exceptions/tests.py @@ -181,6 +181,25 @@ def test_do_not_log_when_debug_is_false(self): with self.assertLogs('django.request', 'DEBUG'): ...
3.2
["test_async_and_sync_middleware_chain_async_call (middleware_exceptions.tests.MiddlewareNotUsedTests)"]
["test_missing_root_urlconf (middleware_exceptions.tests.RootUrlconfTests)", "test_do_not_log_when_debug_is_false (middleware_exceptions.tests.MiddlewareNotUsedTests)", "test_log (middleware_exceptions.tests.MiddlewareNotUsedTests)", "test_log_custom_message (middleware_exceptions.tests.MiddlewareNotUsedTests)", "test_...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13820
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Permit migrations in non-namespace packages that don't have __file__ Description Summary This feature request, for which I will post a PR shortly, aims to improve the specificity of the migration loader's che...
django/django
98ad327864aed8df245fd19ea9d2743279e11643
Permit migrations in non-namespace packages that don't have __file__ Description Summary This feature request, for which I will post a PR shortly, aims to improve the specificity of the migration loader's check for and rejection of ​PEP-420 namespace packages. I am NOT asking to allow namespace packages for apps' mig...
2020-12-28T22:07:57Z
<patch> diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py --- a/django/db/migrations/loader.py +++ b/django/db/migrations/loader.py @@ -88,15 +88,19 @@ def load_disk(self): continue raise else: - # Empty directories are namespa...
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -1,5 +1,6 @@ import compileall import os +from importlib import import_module from django.db import connection, connections from django.db.migrations.except...
3.2
["test_loading_package_without__file__ (migrations.test_loader.LoaderTests)"]
["test_apply (migrations.test_loader.RecorderTests)", "test_invalid (migrations.test_loader.PycLoaderTests)", "test_valid (migrations.test_loader.PycLoaderTests)", "test_check_consistent_history (migrations.test_loader.LoaderTests)", "test_check_consistent_history_squashed (migrations.test_loader.LoaderTests)", "test_e...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13821
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Drop support for SQLite < 3.9.0 Description (last modified by Tim Graham) Indexes on expressions (see #26167) and the SQLITE_ENABLE_JSON1 compile-time option are supported on ​SQLite 3.9.0+. Ubuntu Xeni...
django/django
e64c1d8055a3e476122633da141f16b50f0c4a2d
Drop support for SQLite < 3.9.0 Description (last modified by Tim Graham) Indexes on expressions (see #26167) and the SQLITE_ENABLE_JSON1 compile-time option are supported on ​SQLite 3.9.0+. Ubuntu Xenial ships with SQLite 3.11.0 (which will still by supported by Django) and will EOL in April 2021. Debian Jessi...
2020-12-29T15:16:10Z
<patch> diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -64,8 +64,10 @@ def list_aggregate(function): def check_sqlite_version(): - if Database.sqlite_version_info < (3, 8, 3): - rais...
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -30,9 +30,9 @@ class Tests(TestCase): longMessage = True def test_check_sqlite_version(self): - msg = 'SQLite 3.8.3 or later is required (found 3.8...
3.2
["test_check_sqlite_version (backends.sqlite.tests.Tests)"]
["test_parameter_escaping (backends.sqlite.tests.EscapingChecksDebug)", "test_parameter_escaping (backends.sqlite.tests.EscapingChecks)", "test_large_number_of_parameters (backends.sqlite.tests.LastExecutedQueryTest)", "test_no_interpolation (backends.sqlite.tests.LastExecutedQueryTest)", "test_parameter_quoting (backe...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13837
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Allow autoreloading of `python -m pkg_other_than_django runserver` Description (last modified by William Schwartz) ​django.utils.autoreload.get_child_arguments detects if Python was launched as python -...
django/django
415f50298f97fb17f841a9df38d995ccf347dfcc
Allow autoreloading of `python -m pkg_other_than_django runserver` Description (last modified by William Schwartz) ​django.utils.autoreload.get_child_arguments detects if Python was launched as python -m django. Currently it detects only when ​-m was passed specifically django (and only in Python environments i...
2021-01-04T17:44:23Z
<patch> diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -216,14 +216,14 @@ def get_child_arguments(): executable is reported to not have the .exe extension which can cause bugs on reloading. """ - import django._...
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -23,6 +23,7 @@ from django.utils import autoreload from django.utils.autoreload import WatchmanUnavailable +from .test_module import __mai...
3.2
["test_run_as_non_django_module (utils_tests.test_autoreload.TestChildArguments)"]
["test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception_with_context (utils_tests.test_autoreload.TestRaiseLastExce...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django__django-13925
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> models.W042 is raised on inherited manually specified primary key. Description I have models which inherit from other models, and they should inherit the primary key. This works fine with Django 3.1. However,...
django/django
0c42cdf0d2422f4c080e93594d5d15381d6e955e
models.W042 is raised on inherited manually specified primary key. Description I have models which inherit from other models, and they should inherit the primary key. This works fine with Django 3.1. However, if I install Django 3.2 alpha, when I run make_migrations I get the following error messages: System check id...
Hello Uri, thanks for testing out the alpha and the report. These models should not use auto-created primary keys! I already defined the primary key in the ancestor of the model. For example class Entity which class User inherits from. It looks to me like a bug in Django 3.2 alpha. Could you provide a minimal project w...
2021-01-21T08:08:55Z
<patch> diff --git a/django/db/models/base.py b/django/db/models/base.py --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -1299,6 +1299,11 @@ def check(cls, **kwargs): def _check_default_pk(cls): if ( cls._meta.pk.auto_created and + # Inherited PKs are checked in pa...
diff --git a/tests/check_framework/test_model_checks.py b/tests/check_framework/test_model_checks.py --- a/tests/check_framework/test_model_checks.py +++ b/tests/check_framework/test_model_checks.py @@ -376,23 +376,62 @@ def mocked_is_overridden(self, setting): @isolate_apps('check_framework.apps.CheckDefaultPKConfig'...
4.0
["test_auto_created_inherited_pk (check_framework.test_model_checks.ModelDefaultAutoFieldTests)", "test_explicit_inherited_pk (check_framework.test_model_checks.ModelDefaultAutoFieldTests)"]
["test_app_default_auto_field (check_framework.test_model_checks.ModelDefaultAutoFieldTests)", "test_auto_created_inherited_parent_link (check_framework.test_model_checks.ModelDefaultAutoFieldTests)", "test_auto_created_pk (check_framework.test_model_checks.ModelDefaultAutoFieldTests)", "test_default_auto_field_setting...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-13933
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ModelChoiceField does not provide value of invalid choice when raising ValidationError Description (last modified by Aaron Wiegel) Compared with ChoiceField and others, ModelChoiceField does not show th...
django/django
42e8cf47c7ee2db238bf91197ea398126c546741
ModelChoiceField does not provide value of invalid choice when raising ValidationError Description (last modified by Aaron Wiegel) Compared with ChoiceField and others, ModelChoiceField does not show the value of the invalid choice when raising a validation error. Passing in parameters with the invalid value an...
This message has been the same literally forever b2b6fc8e3c78671c8b6af2709358c3213c84d119. ​Given that ChoiceField passes the value when raising the error, if you set ​error_messages you should be able to get the result you want. Replying to Carlton Gibson: This message has been the same literally forever b2b6fc8e3c786...
2021-01-26T03:58:23Z
<patch> diff --git a/django/forms/models.py b/django/forms/models.py --- a/django/forms/models.py +++ b/django/forms/models.py @@ -1284,7 +1284,11 @@ def to_python(self, value): value = getattr(value, key) value = self.queryset.get(**{key: value}) except (ValueError, TypeError, se...
diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py --- a/tests/forms_tests/tests/test_error_messages.py +++ b/tests/forms_tests/tests/test_error_messages.py @@ -308,3 +308,16 @@ def test_modelchoicefield(self): self.assertFormErrors(['REQUIRED'], f.clea...
4.0
["test_modelchoicefield_value_placeholder (forms_tests.tests.test_error_messages.ModelChoiceFieldErrorMessagesTestCase)"]
["test_modelchoicefield (forms_tests.tests.test_error_messages.ModelChoiceFieldErrorMessagesTestCase)", "test_booleanfield (forms_tests.tests.test_error_messages.FormsErrorMessagesTestCase)", "test_charfield (forms_tests.tests.test_error_messages.FormsErrorMessagesTestCase)", "test_choicefield (forms_tests.tests.test_e...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-13964
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Saving parent object after setting on child leads to data loss for parents with non-numeric primary key. Description (last modified by Charlie DeTar) Given a model with a foreign key relation to another...
django/django
f39634ff229887bf7790c069d0c411b38494ca38
Saving parent object after setting on child leads to data loss for parents with non-numeric primary key. Description (last modified by Charlie DeTar) Given a model with a foreign key relation to another model that has a non-auto CharField as its primary key: class Product(models.Model): sku = models.CharField(...
Thanks for this report. product_id is an empty string in ​_prepare_related_fields_for_save() that's why pk from a related object is not used. We could use empty_values: diff --git a/django/db/models/base.py b/django/db/models/base.py index 822aad080d..8e7a8e3ae7 100644 --- a/django/db/models/base.py +++ b/django/db/mod...
2021-02-02T17:07:43Z
<patch> diff --git a/django/db/models/base.py b/django/db/models/base.py --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -933,7 +933,7 @@ def _prepare_related_fields_for_save(self, operation_name): "%s() prohibited to prevent data loss due to unsaved " ...
diff --git a/tests/many_to_one/models.py b/tests/many_to_one/models.py --- a/tests/many_to_one/models.py +++ b/tests/many_to_one/models.py @@ -68,6 +68,10 @@ class Parent(models.Model): bestchild = models.ForeignKey('Child', models.SET_NULL, null=True, related_name='favored_by') +class ParentStringPrimaryKey(m...
4.0
["test_save_fk_after_parent_with_non_numeric_pk_set_on_child (many_to_one.tests.ManyToOneTests)"]
["test_add (many_to_one.tests.ManyToOneTests)", "test_add_after_prefetch (many_to_one.tests.ManyToOneTests)", "test_add_remove_set_by_pk_raises (many_to_one.tests.ManyToOneTests)", "test_add_then_remove_after_prefetch (many_to_one.tests.ManyToOneTests)", "test_assign (many_to_one.tests.ManyToOneTests)", "test_assign_fk...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14007
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Database converters (from_db_value) not called for returning_fields on insert Description Making a subclass of BigAutoField, I've found that, unlike all other query pathways, on insert the returned integer is...
django/django
619f26d2895d121854b1bed1b535d42b722e2eba
Database converters (from_db_value) not called for returning_fields on insert Description Making a subclass of BigAutoField, I've found that, unlike all other query pathways, on insert the returned integer is not passed through any database converters defined for the field - including the from_db_value hook. This mea...
2021-02-13T09:00:02Z
<patch> diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1405,6 +1405,7 @@ def execute_sql(self, returning_fields=None): returning_fields and len(self.query.objs) != 1 and not self...
diff --git a/tests/custom_pk/fields.py b/tests/custom_pk/fields.py --- a/tests/custom_pk/fields.py +++ b/tests/custom_pk/fields.py @@ -20,7 +20,7 @@ def __eq__(self, other): return self.value == other -class MyAutoField(models.CharField): +class MyWrapperField(models.CharField): def __init__(self, *...
4.0
["test_auto_field_subclass_create (custom_pk.tests.CustomPKTests)"]
["Get can accept pk or the real attribute name", "Custom pks work with in_bulk, both for integer and non-integer types", "pk and attribute name are available on the model", "Both pk and custom attribute_name can be used in filter and friends", "Custom pk doesn't affect related_name based lookups", "Queries across table...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14011
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> LiveServerTestCase's ThreadedWSGIServer doesn't close database connections after each thread Description In Django 2.2.17, I'm seeing the reappearance of #22414 after it was fixed in 1.11. #22414 is the issue...
django/django
e4430f22c8e3d29ce5d9d0263fba57121938d06d
LiveServerTestCase's ThreadedWSGIServer doesn't close database connections after each thread Description In Django 2.2.17, I'm seeing the reappearance of #22414 after it was fixed in 1.11. #22414 is the issue where the following error will occur at the conclusion of a test run when destroy_test_db() is called: Operat...
I wonder if this issue is because ThreadingMixIn creates a new thread for each request, but those threads don't close their database connections at their conclusion, e.g. like LiveServerThread does. Here is the code in CPython for ThreadingMixIn's process_request() and server_close(): ​https://github.com/python/cpython...
2021-02-15T06:15:21Z
<patch> 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 @@ -16,6 +16,7 @@ from django.core.exceptions import ImproperlyConfigured from django.core.handlers.wsgi import LimitedStream from django.core.wsgi import...
diff --git a/django/test/testcases.py b/django/test/testcases.py --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1513,11 +1513,12 @@ def run(self): finally: connections.close_all() - def _create_server(self): + def _create_server(self, connections_override=None): ...
4.0
["test_live_server_url_is_class_property (servers.tests.LiveServerAddress)", "Data written to the database by a view can be read.", "Fixtures are properly loaded and visible to the live server thread.", "test_check_model_instance_from_subview (servers.tests.LiveServerThreadedTests)", "test_view_calls_subview (servers.t...
["test_set_up_class (servers.tests.LiveServerTestCaseSetupTest)", "Contrast to"]
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14017
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Q(...) & Exists(...) raises a TypeError Description Exists(...) & Q(...) works, but Q(...) & Exists(...) raise a TypeError Here's a minimal example: In [3]: Exists(Product.objects.all()) & Q() Out[3]: <Q: (AN...
django/django
466920f6d726eee90d5566e0a9948e92b33a122e
Q(...) & Exists(...) raises a TypeError Description Exists(...) & Q(...) works, but Q(...) & Exists(...) raise a TypeError Here's a minimal example: In [3]: Exists(Product.objects.all()) & Q() Out[3]: <Q: (AND: <django.db.models.expressions.Exists object at 0x7fc18dd0ed90>, (AND: ))> In [4]: Q() & Exists(Product.obje...
Reproduced on 3.1.6. The exception is raised by this two lines in the Q._combine, which are not present in the Combinable._combine from which Exists inherit. if not isinstance(other, Q): raise TypeError(other) Tests: diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 08ea0a51d3..20d0404f44 10064...
2021-02-18T13:05:27Z
<patch> diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -40,7 +40,7 @@ def __init__(self, *args, _connector=None, _negated=False, **kwargs): super().__init__(children=[*args, *sorted(kwargs.items())], ...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -815,6 +815,28 @@ def test_boolean_expression_combined(self): Employee.objects.filter(Exists(is_poc) | Q(salary__lt=15)), [self.example_inc.ceo, self.max], ...
4.0
["test_boolean_expression_combined (expressions.tests.BasicExpressionsTests)", "test_boolean_expression_combined_with_empty_Q (expressions.tests.BasicExpressionsTests)"]
["test_resolve_output_field (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_and (expressions....
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14034
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> MultiValueField ignores a required value of a sub field Description (last modified by Takayuki Hirai) A field and a form definition: from django.forms import ( Form, CharField, MultiValueField, Mult...
django/django
db1fc5cd3c5d36cdb5d0fe4404efd6623dd3e8fb
MultiValueField ignores a required value of a sub field Description (last modified by Takayuki Hirai) A field and a form definition: from django.forms import ( Form, CharField, MultiValueField, MultiWidget, ) class MF(MultiValueField): widget = MultiWidget def __init__(self): fields = [ CharField(req...
Why do you pass required=False in super(MF, self).__init__()? Removing that seems to resolve the issue. I tried to remove required=False, then both INPUT elements in HTML became required. <tr><th><label for="id_mf_0">Mf:</label></th><td><input type="text" name="mf_0" required id="id_mf_0" /> <input type="text" name="mf...
2021-02-22T19:32:50Z
<patch> diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError from django.forms.utils import flatatt, pretty_name -from django.forms.widgets import Textarea, TextInput ...
diff --git a/tests/forms_tests/field_tests/test_multivaluefield.py b/tests/forms_tests/field_tests/test_multivaluefield.py --- a/tests/forms_tests/field_tests/test_multivaluefield.py +++ b/tests/forms_tests/field_tests/test_multivaluefield.py @@ -10,6 +10,20 @@ beatles = (('J', 'John'), ('P', 'Paul'), ('G', 'George'),...
4.0
["test_render_required_attributes (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)"]
["test_bad_choice (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_clean (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_clean_disabled_multivalue (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_disabled_has_changed (forms_tests.field_tests...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14053
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> HashedFilesMixin's post_process() yields multiple times for the same file Description As part of fixing #24452, the implementation of HashedFilesMixin (used by both ManifestStaticFilesStorage and CachedStatic...
django/django
179ee13eb37348cd87169a198aec18fedccc8668
HashedFilesMixin's post_process() yields multiple times for the same file Description As part of fixing #24452, the implementation of HashedFilesMixin (used by both ManifestStaticFilesStorage and CachedStaticFilesStorage) was changed such that it performs several passes against the found files, therefore ensuring tha...
I believe I am running into this as well, which has effectively broken my collectstatic files process. I created a new Django 1.11 project with the admin app enabled. It tries to collect all the admin app files, and during the post-process, it constantly loops, and generates new hashes for the same file until it hits t...
2021-02-25T23:57:27Z
<patch> diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -226,17 +226,25 @@ def post_process(self, paths, dry_run=False, **options): path for path in paths if ma...
diff --git a/tests/staticfiles_tests/test_storage.py b/tests/staticfiles_tests/test_storage.py --- a/tests/staticfiles_tests/test_storage.py +++ b/tests/staticfiles_tests/test_storage.py @@ -203,6 +203,8 @@ def test_post_processing(self): self.assertIn(os.path.join('cached', 'css', 'window.css'), stats['post_p...
4.0
["post_processing behaves correctly."]
["test_hashed_name (staticfiles_tests.test_storage.TestCollectionNoneHashStorage)", "test_collect_static_files_default_permissions (staticfiles_tests.test_storage.TestStaticFilePermissions)", "test_collect_static_files_permissions (staticfiles_tests.test_storage.TestStaticFilePermissions)", "test_collect_static_files_s...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14089
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Allow calling reversed() on an OrderedSet Description Currently, ​OrderedSet isn't reversible (i.e. allowed to be passed as an argument to Python's ​reversed()). This would be natural to support given that Or...
django/django
d01709aae21de9cd2565b9c52f32732ea28a2d98
Allow calling reversed() on an OrderedSet Description Currently, ​OrderedSet isn't reversible (i.e. allowed to be passed as an argument to Python's ​reversed()). This would be natural to support given that OrderedSet is ordered. This should be straightforward to add by adding a __reversed__() method to OrderedSet.
2021-03-06T20:51:08Z
<patch> diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -25,6 +25,9 @@ def discard(self, item): def __iter__(self): return iter(self.dict) + def __reversed__(self): + return reversed(self....
diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -1,7 +1,7 @@ """ Tests for stuff in django.utils.datastructures. """ - +import collections.abc import copy import pickle ...
4.0
["test_reversed (utils_tests.test_datastructures.OrderedSetTests)"]
["test_copy (utils_tests.test_datastructures.CaseInsensitiveMappingTests)", "test_create_with_invalid_key (utils_tests.test_datastructures.CaseInsensitiveMappingTests)", "test_create_with_invalid_values (utils_tests.test_datastructures.CaseInsensitiveMappingTests)", "test_del (utils_tests.test_datastructures.CaseInsens...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14122
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Meta.ordering fields must not be included in GROUP BY clause Description This continues (closed) [1] ticket. I beleave it was not properly fixed in commit [0ddb4ebf]. While commit [0ddb4ebf] removes ORDER BY ...
django/django
bc04941bf811d1ea2c79fb7fc20457ed2c7e3410
Meta.ordering fields must not be included in GROUP BY clause Description This continues (closed) [1] ticket. I beleave it was not properly fixed in commit [0ddb4ebf]. While commit [0ddb4ebf] removes ORDER BY when Meta.ordering is used it still does populates GROUP BY with Meta.ordering fields thus leads to wrong aggr...
2021-03-13T19:57:16Z
<patch> diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -125,11 +125,12 @@ def get_group_by(self, select, order_by): cols = expr.get_group_by_cols() for col in cols: ...
diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py --- a/tests/ordering/tests.py +++ b/tests/ordering/tests.py @@ -2,7 +2,7 @@ from operator import attrgetter from django.db.models import ( - CharField, DateTimeField, F, Max, OuterRef, Subquery, Value, + CharField, Count, DateTimeField, F, Max, Ou...
4.0
["test_default_ordering_does_not_affect_group_by (ordering.tests.OrderingTests)"]
["By default, Article.objects.all() orders by pub_date descending, then", "F expressions can be used in Meta.ordering.", "Override ordering with order_by, which is in the same format as the", "Ordering can be based on fields included from an 'extra' clause", "If the extra clause uses an SQL keyword for a name, it will ...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14140
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Combining Q() objects with boolean expressions crashes. Description (last modified by jonathan-golorry) Currently Q objects with 1 child are treated differently during deconstruct. >>> from django.db.mo...
django/django
45814af6197cfd8f4dc72ee43b90ecde305a1d5a
Combining Q() objects with boolean expressions crashes. Description (last modified by jonathan-golorry) Currently Q objects with 1 child are treated differently during deconstruct. >>> from django.db.models import Q >>> Q(x=1).deconstruct() ('django.db.models.Q', (), {'x': 1}) >>> Q(x=1, y=2).deconstruct() ('dj...
Conditional expressions can be combined together, so it's not necessary to encapsulate Exists() with Q(). Moreover it's an undocumented and untested to pass conditional expressions to Q(). Nevertheless I think it makes sense to support this. There is no need to change the current format of deconstruct(), it should be e...
2021-03-17T11:37:55Z
<patch> diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -84,14 +84,10 @@ def deconstruct(self): path = '%s.%s' % (self.__class__.__module__, self.__class__.__name__) if path.startswith('django...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -833,11 +833,21 @@ def test_boolean_expression_combined_with_empty_Q(self): Q() & Exists(is_poc), Exists(is_poc) | Q(), Q() | Exists(is_poc), +...
4.0
["test_deconstruct (queries.test_q.QTests)", "test_deconstruct_boolean_expression (queries.test_q.QTests)", "test_deconstruct_negated (queries.test_q.QTests)", "test_boolean_expression_combined_with_empty_Q (expressions.tests.BasicExpressionsTests)"]
["test_aggregates (expressions.tests.ReprTests)", "test_distinct_aggregates (expressions.tests.ReprTests)", "test_expressions (expressions.tests.ReprTests)", "test_filtered_aggregates (expressions.tests.ReprTests)", "test_functions (expressions.tests.ReprTests)", "test_empty_group_by (expressions.tests.ExpressionWrappe...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14155
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ResolverMatch.__repr__() doesn't handle functools.partial() nicely. Description (last modified by Nick Pope) When a partial function is passed as the view, the __repr__ shows the func argument as functo...
django/django
2f13c476abe4ba787b6cb71131818341911f43cc
ResolverMatch.__repr__() doesn't handle functools.partial() nicely. Description (last modified by Nick Pope) When a partial function is passed as the view, the __repr__ shows the func argument as functools.partial which isn't very helpful, especially as it doesn't reveal the underlying function or arguments pro...
2021-03-19T15:44:25Z
<patch> diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -59,9 +59,16 @@ def __getitem__(self, index): return (self.func, self.args, self.kwargs)[index] def __repr__(self): - return "ResolverMatch(func=%s, args=%s, k...
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -1141,10 +1141,30 @@ def test_repr(self): self.assertEqual( repr(resolve('/no_kwargs/42/37/')), "ResolverMatch(func...
4.0
["test_repr (urlpatterns_reverse.tests.ResolverMatchTests)", "test_repr_functools_partial (urlpatterns_reverse.tests.ResolverMatchTests)", "test_resolver_match_on_request (urlpatterns_reverse.tests.ResolverMatchTests)"]
["test_include_2_tuple (urlpatterns_reverse.tests.IncludeTests)", "test_include_2_tuple_namespace (urlpatterns_reverse.tests.IncludeTests)", "test_include_3_tuple (urlpatterns_reverse.tests.IncludeTests)", "test_include_3_tuple_namespace (urlpatterns_reverse.tests.IncludeTests)", "test_include_4_tuple (urlpatterns_reve...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14170
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Query optimization in YearLookup breaks filtering by "__iso_year" Description (last modified by Florian Demmer) The optimization to use BETWEEN instead of the EXTRACT operation in ​YearLookup is also re...
django/django
6efc35b4fe3009666e56a60af0675d7d532bf4ff
Query optimization in YearLookup breaks filtering by "__iso_year" Description (last modified by Florian Demmer) The optimization to use BETWEEN instead of the EXTRACT operation in ​YearLookup is also registered for the ​"__iso_year" lookup, which breaks the functionality provided by ​ExtractIsoYear when used vi...
2021-03-23T08:53:41Z
<patch> diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py --- a/django/db/backends/base/operations.py +++ b/django/db/backends/base/operations.py @@ -526,30 +526,46 @@ def adapt_ipaddressfield_value(self, value): """ return value or None - def year_lookup_...
diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py --- a/tests/db_functions/datetime/test_extract_trunc.py +++ b/tests/db_functions/datetime/test_extract_trunc.py @@ -359,9 +359,9 @@ def test_extract_iso_year_func_boundaries(self): week_52_day...
4.0
["test_extract_iso_year_func_boundaries (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_iso_year_func_boundaries (db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests)"]
["test_extract_day_func (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_unsupported_lookups (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_without_native_duration_field (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extra...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14238
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> DEFAULT_AUTO_FIELD subclass check fails for subclasses of BigAutoField and SmallAutoField. Description Set DEFAULT_AUTO_FIELD = "example.core.models.MyBigAutoField" , with contents of example.core.models: fro...
django/django
30e123ed351317b7527f632b3b7dc4e81e850449
DEFAULT_AUTO_FIELD subclass check fails for subclasses of BigAutoField and SmallAutoField. Description Set DEFAULT_AUTO_FIELD = "example.core.models.MyBigAutoField" , with contents of example.core.models: from django.db import models class MyBigAutoField(models.BigAutoField): pass class MyModel(models.Model): pass ...
2021-04-08T10:41:31Z
<patch> diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -2524,7 +2524,7 @@ def __instancecheck__(self, instance): return isinstance(instance, self._subclasses) or super().__instancechec...
diff --git a/tests/model_fields/test_autofield.py b/tests/model_fields/test_autofield.py --- a/tests/model_fields/test_autofield.py +++ b/tests/model_fields/test_autofield.py @@ -30,6 +30,18 @@ def test_isinstance_of_autofield(self): self.assertIsInstance(field(), models.AutoField) def test_issu...
4.0
["test_issubclass_of_autofield (model_fields.test_autofield.AutoFieldInheritanceTests)", "test_default_auto_field_setting_bigautofield_subclass (model_options.test_default_pk.TestDefaultPK)"]
["test_isinstance_of_autofield (model_fields.test_autofield.AutoFieldInheritanceTests)", "Backend specific ranges can be saved without corruption.", "Backend specific ranges are enforced at the model validation level", "test_coercing (model_fields.test_autofield.AutoFieldTests)", "Values within the documented safe rang...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14311
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Allow autoreloading of `python -m custom_module runserver` Description (last modified by Mariusz Felisiak) The original fix [1] only attempted to deal with -m foo.bar where bar is a package and __main__...
django/django
5a8e8f80bb82a867eab7e4d9d099f21d0a976d22
Allow autoreloading of `python -m custom_module runserver` Description (last modified by Mariusz Felisiak) The original fix [1] only attempted to deal with -m foo.bar where bar is a package and __main__.py exists under foo/bar. When a dotted name for a module (for example, foo.bar.baz where baz.py resides under...
Patch It doesn't work in Django 3.1 so I would not call it a regression. Can you send PR via GitHub? Looks fine. The one change I'd make is that I'd change modspec.name.split(".")[-1] == "__main__" to modspec.name == "__main__" or modspec.name.endswith(".__main__") to avoid dumb corner cases like a module named foo.my_...
2021-04-25T02:54:34Z
<patch> diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -223,8 +223,13 @@ def get_child_arguments(): # __spec__ is set when the server was started with the `-m` option, # see https://docs.python.org/3/reference/import.ht...
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -23,7 +23,7 @@ from django.utils import autoreload from django.utils.autoreload import WatchmanUnavailable -from .test_module import __mai...
4.0
["test_run_as_non_django_module_non_package (utils_tests.test_autoreload.TestChildArguments)"]
["test_is_django_module (utils_tests.test_autoreload.TestUtilities)", "test_is_django_path (utils_tests.test_autoreload.TestUtilities)", "test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14315
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> database client runshell doesn't respect os.environ values in some cases Description (last modified by Konstantin Alekseev) postgresql client returns empty dict instead of None for env as a result os.en...
django/django
187118203197801c6cb72dc8b06b714b23b6dd3d
database client runshell doesn't respect os.environ values in some cases Description (last modified by Konstantin Alekseev) postgresql client returns empty dict instead of None for env as a result os.environ is not used and empty env passed to subprocess. Bug introduced in ​https://github.com/django/django/comm...
2021-04-26T12:39:01Z
<patch> diff --git a/django/db/backends/base/client.py b/django/db/backends/base/client.py --- a/django/db/backends/base/client.py +++ b/django/db/backends/base/client.py @@ -21,6 +21,5 @@ def settings_to_cmd_args_env(cls, settings_dict, parameters): def runshell(self, parameters): args, env = self.sett...
diff --git a/tests/backends/base/test_client.py b/tests/backends/base/test_client.py --- a/tests/backends/base/test_client.py +++ b/tests/backends/base/test_client.py @@ -1,3 +1,5 @@ +from unittest import mock + from django.db import connection from django.db.backends.base.client import BaseDatabaseClient from djang...
4.0
["test_runshell_use_environ (backends.base.test_client.SimpleDatabaseClientTests)", "test_settings_to_cmd_args_env (backends.base.test_client.SimpleDatabaseClientTests)", "test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "t...
[]
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14349
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> URLValidator tests failing on Python versions patched for bpo-43882 Description On Python versions with a fix for ​bpo-43882 (i.e. 3.10.0b1 and the 3.9 git branch, not released yet) the following tests fail: ...
django/django
a708f39ce67af174df90c5b5e50ad1976cec7cb8
URLValidator tests failing on Python versions patched for bpo-43882 Description On Python versions with a fix for ​bpo-43882 (i.e. 3.10.0b1 and the 3.9 git branch, not released yet) the following tests fail: ====================================================================== FAIL: test_validators (validators.tests...
Thanks for the report. We noticed this issue. Duplicate of #32074. For the record, I was wrong that this hasn't been released in 3.9 -- it's part of 3.9.5. It looks that it will be backported to all supported versions of Python.
2021-05-04T20:10:27Z
<patch> diff --git a/django/core/validators.py b/django/core/validators.py --- a/django/core/validators.py +++ b/django/core/validators.py @@ -92,6 +92,7 @@ class URLValidator(RegexValidator): r'\Z', re.IGNORECASE) message = _('Enter a valid URL.') schemes = ['http', 'https', 'ftp', 'ftps'] + unsa...
diff --git a/tests/validators/tests.py b/tests/validators/tests.py --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -226,9 +226,15 @@ (URLValidator(), None, ValidationError), (URLValidator(), 56, ValidationError), (URLValidator(), 'no_scheme', ValidationError), - # Trailing newlines ...
4.0
["test_validators (validators.tests.TestValidators)"]
["test_domain_whitelist (validators.tests.DeprecationTests)", "test_domain_whitelist_access_warning (validators.tests.DeprecationTests)", "test_domain_whitelist_set_warning (validators.tests.DeprecationTests)", "test_whitelist (validators.tests.DeprecationTests)", "test_whitelist_warning (validators.tests.DeprecationTe...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14351
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Q object __or__ appears to get all dunder related's default columns and queryset raises ProgrammingError. Description There appears to be a difference in how Q object aliases are setup, when OR'd. The get_def...
django/django
06fd4df41afb5aa1d681b853c3c08d8c688ca3a5
Q object __or__ appears to get all dunder related's default columns and queryset raises ProgrammingError. Description There appears to be a difference in how Q object aliases are setup, when OR'd. The get_default_columns for this agent__property_groups__id__in only uses 1, where as get_default_columns for this agent_...
Thanks for the report. Can you provide a sample project? (models definition and a complete queryset). I cannot reproduce this issue with provided details. Replying to Mariusz Felisiak: Thanks for the report. Can you provide a sample project? (models definition and a complete queryset). I cannot reproduce this issue wit...
2021-05-05T03:50:44Z
<patch> diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -406,6 +406,15 @@ def process_rhs(self, compiler, connection): self.rhs.add_fields(['pk']) return super().process_rhs(compiler, connection) ...
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -1525,6 +1525,14 @@ class DistinctAggregate(Aggregate): allow_distinct = True DistinctAggregate('foo', distinct=True) + @sk...
4.0
["test_having_subquery_select (aggregation_regress.tests.AggregationTests)"]
["test_ticket_24748 (aggregation_regress.tests.SelfReferentialFKTests)", "test_existing_join_not_promoted (aggregation_regress.tests.JoinPromotionTests)", "test_non_nullable_fk_not_promoted (aggregation_regress.tests.JoinPromotionTests)", "test_ticket_21150 (aggregation_regress.tests.JoinPromotionTests)", "test_aggrega...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14373
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> DateFormat.Y() is not zero-padded. Description The Y specifier for django.utils.dateformat.DateFormat is supposed to always return a four-digit year padded with zeros. This doesn't seem to be the case for yea...
django/django
b1a4b1f0bdf05adbd3dc4dde14228e68da54c1a3
DateFormat.Y() is not zero-padded. Description The Y specifier for django.utils.dateformat.DateFormat is supposed to always return a four-digit year padded with zeros. This doesn't seem to be the case for year < 1000.
2021-05-10T14:40:32Z
<patch> diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py --- a/django/utils/dateformat.py +++ b/django/utils/dateformat.py @@ -313,8 +313,8 @@ def y(self): return '%02d' % (self.data.year % 100) def Y(self): - "Year, 4 digits; e.g. '1999'" - return self.data.year + ...
diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py --- a/tests/utils_tests/test_dateformat.py +++ b/tests/utils_tests/test_dateformat.py @@ -166,7 +166,7 @@ def test_r_format_with_non_en_locale(self): 'Sun, 08 Jul 1979 22:00:00 +0100', ) - def tes...
4.0
["test_Y_format_year_before_1000 (utils_tests.test_dateformat.DateFormatTests)"]
["test_am_pm (utils_tests.test_dateformat.DateFormatTests)", "test_date (utils_tests.test_dateformat.DateFormatTests)", "test_date_formats (utils_tests.test_dateformat.DateFormatTests)", "test_dateformat (utils_tests.test_dateformat.DateFormatTests)", "test_datetime_with_local_tzinfo (utils_tests.test_dateformat.DateFo...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14376
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> MySQL backend uses deprecated "db" and "passwd" kwargs. Description The "db" and "passwd" usage can be seen at ​https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/db/backend...
django/django
d06c5b358149c02a62da8a5469264d05f29ac659
MySQL backend uses deprecated "db" and "passwd" kwargs. Description The "db" and "passwd" usage can be seen at ​https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/db/backends/mysql/base.py#L202-L205 in main. mysqlclient recently marked these two kwargs as deprecated (see ​https://gi...
Thanks for this report. Django 2.2, 3.1, and 3.2 all require a minimum version of mysqlclient newer than 1.3.8, so a fix for this could be backported to all currently supported versions of Django. Django 2.2 and 3.1 are in extended support so they don't receive bugfixes anymore (except security patches). We'll document...
2021-05-10T20:42:18Z
<patch> diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -200,9 +200,9 @@ def get_connection_params(self): if settings_dict['USER']: kwargs['user'] = settings_dict['USER'] if s...
diff --git a/tests/dbshell/test_mysql.py b/tests/dbshell/test_mysql.py --- a/tests/dbshell/test_mysql.py +++ b/tests/dbshell/test_mysql.py @@ -50,41 +50,49 @@ def test_options_override_settings_proper_values(self): 'optiondbname', ] expected_env = {'MYSQL_PWD': 'optionpassword'} - ...
4.0
["test_options_non_deprecated_keys_preferred (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_options_override_settings_proper_values (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_parameters (dbshell.test_mysql.MySqlDbshellCommandTestCase)"]
["test_basic_params_specified_in_settings (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_can_connect_using_sockets (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_crash_password_does_not_leak (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_fails_with_keyerror_on_incomplete_config (dbshell.te...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14404
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> catch_all_view() does not support FORCE_SCRIPT_NAME. Description (last modified by SlavaSkvortsov) catch_all_view returns redirect to '%s/' % request.path_info (script name cut off there) instead of '%s...
django/django
de32fe83a2e4a20887972c69a0693b94eb25a88b
catch_all_view() does not support FORCE_SCRIPT_NAME. Description (last modified by SlavaSkvortsov) catch_all_view returns redirect to '%s/' % request.path_info (script name cut off there) instead of '%s/' % request.path (with the script name) Patch - ​https://github.com/django/django/pull/14404
2021-05-17T11:24:06Z
<patch> 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 @@ -420,14 +420,13 @@ def autocomplete_view(self, request): def catch_all_view(self, request, url): if settings.APPEND_SLASH and not url.endswith('/'):...
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 @@ -6602,6 +6602,42 @@ def test_missing_slash_append_slash_true(self): response = self.client.get(known_url[:-1]) self.assertRedirects(response, known_url, status_code...
4.0
["test_missing_slash_append_slash_true_force_script_name (admin_views.tests.AdminSiteFinalCatchAllPatternTests)", "test_missing_slash_append_slash_true_script_name (admin_views.tests.AdminSiteFinalCatchAllPatternTests)"]
["test_explicitly_provided_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_implicitly_generated_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_should_be_able_to_edit_related_objects_on_add_view (admin_views.tests.AdminCustomSaveRelatedTests)", "test_should_be_able_to_edit_related_ob...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14434
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Statement created by _create_unique_sql makes references_column always false Description This is due to an instance of Table is passed as an argument to Columns when a string is expected. </issue> <code> [st...
django/django
5e04e84d67da8163f365e9f5fcd169e2630e2873
Statement created by _create_unique_sql makes references_column always false Description This is due to an instance of Table is passed as an argument to Columns when a string is expected.
2021-05-23T12:27:14Z
<patch> 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 @@ -1241,9 +1241,9 @@ def create_unique_name(*args, **kwargs): return self.quote_name(self._create_index_name(*args, **kwargs)) ...
diff --git a/tests/schema/tests.py b/tests/schema/tests.py --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2198,6 +2198,22 @@ def test_remove_unique_together_does_not_remove_meta_constraints(self): AuthorWithUniqueNameAndBirthday._meta.constraints = [] editor.remove_constraint(Auth...
4.0
["test_unique_constraint (schema.tests.SchemaTests)"]
["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14493
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ManifestStaticFilesStorage crashes with max_post_process_passes = 0. Description To reproduce: Derive a custom class from ManifestStaticFilesStorage and set max_post_process_passes to 0: class MyManifestStati...
django/django
7272e1963ffdf39c1d4fe225d5425a45dd095d11
ManifestStaticFilesStorage crashes with max_post_process_passes = 0. Description To reproduce: Derive a custom class from ManifestStaticFilesStorage and set max_post_process_passes to 0: class MyManifestStaticFilesStorage(ManifestStaticFilesStorage): max_post_process_passes = 0 # settings.py STATICFILES_STORAGE = "M...
An effective workaround is overriding patterns = (). It might not be worth fixing the UnboundLocalError. I think it's worth fixing. Hi guys, Can I work on this? Replying to kingliar420: Can I work on this? Sure there is no need to ask. Please remember that a regression test is required.
2021-06-05T12:50:25Z
<patch> diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -260,6 +260,7 @@ def post_process(self, paths, dry_run=False, **options): processed_adjustable_paths[name] = (nam...
diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py --- a/tests/staticfiles_tests/storage.py +++ b/tests/staticfiles_tests/storage.py @@ -97,3 +97,7 @@ class ExtraPatternsStorage(ManifestStaticFilesStorage): class NoneHashStorage(ManifestStaticFilesStorage): def file_hash(self, na...
4.0
["test_collectstatistic_no_post_process_replaced_paths (staticfiles_tests.test_storage.TestCollectionNoPostProcessReplacedPaths)"]
["test_hashed_name (staticfiles_tests.test_storage.TestCollectionNoneHashStorage)", "With storage classes having several file extension patterns, only the", "test_collect_static_files_default_permissions (staticfiles_tests.test_storage.TestStaticFilePermissions)", "test_collect_static_files_permissions (staticfiles_tes...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14500
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Squashed migration is not marked as unapplied Description (last modified by Markus Holtermann) When unapplying a squashed migration and the replaced migration files are still around, the MigrationExecut...
django/django
8c3bd0b708b488a1f6e8bd8cc6b96569904605be
Squashed migration is not marked as unapplied Description (last modified by Markus Holtermann) When unapplying a squashed migration and the replaced migration files are still around, the MigrationExecutor mark the squash migration as unapplied, too, not only the replaced migrations.
While working on #24800 I realized that the issue is actually not fully correct. The squashed migration is not marked as applied. PR: ​https://github.com/django/django/pull/5280 The commit this depends on is moved to "Work in progress" status, so moving this off the checkin queue. Updated ticket, since original PR was ...
2021-06-08T05:08:08Z
<patch> diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py --- a/django/db/migrations/executor.py +++ b/django/db/migrations/executor.py @@ -250,12 +250,11 @@ def unapply_migration(self, state, migration, fake=False): if not fake: with self.connection.schema_editor(at...
diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py --- a/tests/migrations/test_executor.py +++ b/tests/migrations/test_executor.py @@ -653,6 +653,23 @@ def test_migrate_marks_replacement_applied_even_if_it_did_nothing(self): recorder.applied_migrations(), ) + @...
4.0
["test_migrate_marks_replacement_unapplied (migrations.test_executor.ExecutorTests)"]
["If the current state satisfies the given target, do nothing.", "Minimize unnecessary rollbacks in connected apps.", "Minimize rollbacks when target has multiple in-app children.", "test_alter_id_type_with_fk (migrations.test_executor.ExecutorTests)", "Applying all replaced migrations marks replacement as applied (#24...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14534
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> BoundWidget.id_for_label ignores id set by ChoiceWidget.options Description If you look at the implementation of BoundField.subwidgets class BoundField: ... def subwidgets(self): id_ = self.field.widget.a...
django/django
910ecd1b8df7678f45c3d507dde6bcb1faafa243
BoundWidget.id_for_label ignores id set by ChoiceWidget.options Description If you look at the implementation of BoundField.subwidgets class BoundField: ... def subwidgets(self): id_ = self.field.widget.attrs.get('id') or self.auto_id attrs = {'id': id_} if id_ else {} attrs = self.build_widget_attrs(attrs) ...
Hey Jacob — Sounds right: I didn't look in-depth but, if you can put your example in a test case it will be clear enough in the PR. Thanks. Thanks Carlton, I will create a pull request asap. Here is a pull request fixing this bug: ​https://github.com/django/django/pull/14533 (closed without merging) Here is the new pul...
2021-06-17T15:37:34Z
<patch> diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -277,7 +277,7 @@ def template_name(self): @property def id_for_label(self): - return 'id_%s_%s' % (self.data['name'], self.data['index']) + return s...
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -720,7 +720,7 @@ class BeatleForm(Form): fields = list(BeatleForm(auto_id=False)['name']) self.assertEqual(len(fields), ...
4.0
["If auto_id is provided when initializing the form, the generated ID in", "test_iterable_boundfield_select (forms_tests.tests.test_forms.FormsTestCase)"]
["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14539
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> urlize() does not handle html escaped string and trailing punctuation correctly Description Example: urlize('Search for google.com/?q=1&lt! and see.') # expected output 'Search for <a href="http://google.com/...
django/django
6a5ef557f80a8eb6a758ebe99c8bb477ca47459e
urlize() does not handle html escaped string and trailing punctuation correctly Description Example: urlize('Search for google.com/?q=1&lt! and see.') # expected output 'Search for <a href="http://google.com/?q=1%3C">google.com/?q=1&lt</a>! and see.' # actual output 'Search for <a href="http://google.com/?q=1%3C">goo...
​https://github.com/django/django/pull/14539/ OK, thanks, the example looks right. It's always delicate but let's take this for review. Related to #26193.
2021-06-19T11:31:16Z
<patch> diff --git a/django/utils/html.py b/django/utils/html.py --- a/django/utils/html.py +++ b/django/utils/html.py @@ -283,8 +283,9 @@ def trim_punctuation(lead, middle, trail): middle_unescaped = html.unescape(middle) stripped = middle_unescaped.rstrip(TRAILING_PUNCTUATION_CHARS) ...
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -250,6 +250,10 @@ def test_urlize(self): 'Search for google.com/?q=! and see.', 'Search for <a href="http://google.com/?q=">google.c...
4.0
["test_urlize (utils_tests.test_html.TestUtilsHtml)", "test_urlize_unchanged_inputs (utils_tests.test_html.TestUtilsHtml)"]
["test_conditional_escape (utils_tests.test_html.TestUtilsHtml)", "test_escape (utils_tests.test_html.TestUtilsHtml)", "test_escapejs (utils_tests.test_html.TestUtilsHtml)", "test_format_html (utils_tests.test_html.TestUtilsHtml)", "test_html_safe (utils_tests.test_html.TestUtilsHtml)", "test_html_safe_defines_html_err...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14559
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Include number of rows matched in bulk_update() return value Description Currently, bulk_update() returns None, unlike update(), which returns ​the number of rows matched. It looks like it would be easy to ad...
django/django
d79be3ed39b76d3e34431873eec16f6dd354ab17
Include number of rows matched in bulk_update() return value Description Currently, bulk_update() returns None, unlike update(), which returns ​the number of rows matched. It looks like it would be easy to add the same functionality to bulk_update() since bulk_update() simply calls update() repeatedly: ​https://githu...
Also, if this feature is okayed, maybe the number could be returned in a way that would permit other useful numbers to be added to the return value in a backwards-compatible way later on. For example, the number could be returned as a property of a named tuple with one property. That way, if a new value is requested in...
2021-06-26T05:38:46Z
<patch> 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 @@ -541,7 +541,7 @@ def bulk_update(self, objs, fields, batch_size=None): if any(f.primary_key for f in fields): raise ValueError('bulk_update() cannot be used...
diff --git a/tests/queries/test_bulk_update.py b/tests/queries/test_bulk_update.py --- a/tests/queries/test_bulk_update.py +++ b/tests/queries/test_bulk_update.py @@ -125,7 +125,8 @@ def test_update_custom_primary_key(self): def test_empty_objects(self): with self.assertNumQueries(0): - Note....
4.0
["test_empty_objects (queries.test_bulk_update.BulkUpdateTests)", "test_large_batch (queries.test_bulk_update.BulkUpdateTests)", "test_updated_rows_when_passing_duplicates (queries.test_bulk_update.BulkUpdateTests)"]
["test_batch_size (queries.test_bulk_update.BulkUpdateNoteTests)", "test_foreign_keys_do_not_lookup (queries.test_bulk_update.BulkUpdateNoteTests)", "test_functions (queries.test_bulk_update.BulkUpdateNoteTests)", "test_multiple_fields (queries.test_bulk_update.BulkUpdateNoteTests)", "test_set_field_to_null (queries.te...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14580
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Missing import statement in generated migration (NameError: name 'models' is not defined) Description I found a bug in Django's latest release: 3.2.4. Given the following contents of models.py: from django.d...
django/django
36fa071d6ebd18a61c4d7f1b5c9d17106134bd44
Missing import statement in generated migration (NameError: name 'models' is not defined) Description I found a bug in Django's latest release: 3.2.4. Given the following contents of models.py: from django.db import models class MyField(models.TextField): pass class MyBaseModel(models.Model): class Meta: abstrac...
I could reproduce the issue with 3.2.4, 2.2.24 and the main branch. For what it's worth, the issue doesn't occur if the class MyModel does inherit from MyMixin. MyBaseModel is not necessary to reproduce this issue, it's due to the fact that MyModel doesn't have fields from django.db.models and has custom bases. It look...
2021-07-01T07:38:03Z
<patch> diff --git a/django/db/migrations/serializer.py b/django/db/migrations/serializer.py --- a/django/db/migrations/serializer.py +++ b/django/db/migrations/serializer.py @@ -273,7 +273,7 @@ def _format(self): class TypeSerializer(BaseSerializer): def serialize(self): special_cases = [ - (...
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 @@ -658,6 +658,13 @@ def test_serialize_functools_partialmethod(self): def test_serialize_type_none(self): self.assertSerializedEqual(type(None)) + ...
4.0
["test_serialize_type_model (migrations.test_writer.WriterTests)"]
["test_args_kwargs_signature (migrations.test_writer.OperationWriterTests)", "test_args_signature (migrations.test_writer.OperationWriterTests)", "test_empty_signature (migrations.test_writer.OperationWriterTests)", "test_expand_args_signature (migrations.test_writer.OperationWriterTests)", "test_kwargs_signature (migr...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14608
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Add `nonform` CSS class for non form errors in FormSets Description (last modified by Ties Jan Hefting) Forms add the nonfield CSS class for non field errors in ErrorList instances. This is documented i...
django/django
7f33c1e22dbc34a7afae7967783725b10f1f13b1
Add `nonform` CSS class for non form errors in FormSets Description (last modified by Ties Jan Hefting) Forms add the nonfield CSS class for non field errors in ErrorList instances. This is documented in a section on ​rendering form error messages. Similarly, in FormSets I'd expect to see the nonform CSS class ...
Seems reasonable (similar to #11776). ​PR
2021-07-07T19:51:30Z
<patch> diff --git a/django/forms/formsets.py b/django/forms/formsets.py --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -333,7 +333,7 @@ def full_clean(self): self._non_form_errors. """ self._errors = [] - self._non_form_errors = self.error_class() + self._non_...
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 @@ -3348,7 +3348,10 @@ def test_non_form_errors_is_errorlist(self): response = self.client.post(reverse('admin:admin_views_person_changelist'), data) non_form_errors =...
4.0
["If validate_max is set and max_num is less than TOTAL_FORMS in the", "If validate_min is set and min_num is more than TOTAL_FORMS in the", "test_non_form_errors (forms_tests.tests.test_formsets.FormsFormsetTestCase)", "test_non_form_errors_is_errorlist (admin_views.tests.AdminViewListEditable)"]
["all_valid() validates all forms, even when some are invalid.", "test_valid (forms_tests.tests.test_formsets.AllValidTests)", "is_multipart() works with an empty formset.", "An empty formset still calls clean()", "Media is available on empty formset.", "test_customize_management_form_error (forms_tests.tests.test_form...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14631
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> BaseForm's _clean_fields() and changed_data should access values via BoundField Description (last modified by Chris Jerdonek) While working on #32917, I noticed that ​BaseForm._clean_fields() and ​BaseF...
django/django
84400d2e9db7c51fee4e9bb04c028f665b8e7624
BaseForm's _clean_fields() and changed_data should access values via BoundField Description (last modified by Chris Jerdonek) While working on #32917, I noticed that ​BaseForm._clean_fields() and ​BaseForm.changed_data don't currently access their values through a BoundField object. It would be better for consi...
Here is how to make the failing test I mentioned above (roughly): def test_datetime_clean_initial_callable_disabled(self): - now = datetime.datetime(2006, 10, 25, 14, 30, 45, 123456) - class DateTimeForm(forms.Form): - dt = DateTimeField(initial=lambda: now, disabled=True) + dt = DateTimeField(initial=datetime.datetime...
2021-07-13T09:16:48Z
<patch> diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -1,6 +1,7 @@ import datetime import re +from django.core.exceptions import ValidationError from django.forms.utils import flatatt, pretty_name from django.forms.widgets...
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2112,15 +2112,47 @@ class DateTimeForm(Form): self.assertEqual(unbound['hi_without_microsec'].value(), now_no_ms) self....
4.0
["The cleaned value for a form with a disabled DateTimeField and callable", "Cleaning a form with a disabled DateTimeField and callable initial"]
["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14672
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Missing call `make_hashable` on `through_fields` in `ManyToManyRel` Description In 3.2 identity property has been added to all ForeignObjectRel to make it possible to compare them. A hash is derived from said...
django/django
00ea883ef56fb5e092cbe4a6f7ff2e7470886ac4
Missing call `make_hashable` on `through_fields` in `ManyToManyRel` Description In 3.2 identity property has been added to all ForeignObjectRel to make it possible to compare them. A hash is derived from said identity and it's possible because identity is a tuple. To make limit_choices_to hashable (one of this tuple ...
2021-07-20T10:47:34Z
<patch> diff --git a/django/db/models/fields/reverse_related.py b/django/db/models/fields/reverse_related.py --- a/django/db/models/fields/reverse_related.py +++ b/django/db/models/fields/reverse_related.py @@ -310,7 +310,7 @@ def __init__(self, field, to, related_name=None, related_query_name=None, def identity(s...
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -821,6 +821,33 @@ class Child(Parent): ) ]) + def test_field_name_clash_with_m2m_through(self):...
4.0
["test_multiple_autofields (invalid_models_tests.test_models.MultipleAutoFieldsTests)", "test_db_column_clash (invalid_models_tests.test_models.FieldNamesTests)", "test_ending_with_underscore (invalid_models_tests.test_models.FieldNamesTests)", "test_including_separator (invalid_models_tests.test_models.FieldNamesTests...
[]
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14725
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Provide a way for model formsets to disallow new object creation Description Model formsets don't provide a way to create an "edit only" view of objects. We see users trying to use extra=0 to accomplish this,...
django/django
0af9a5fc7d765aa05ea784e2c3237675f3bb4b49
Provide a way for model formsets to disallow new object creation Description Model formsets don't provide a way to create an "edit only" view of objects. We see users trying to use extra=0 to accomplish this, but that's not reliable as extra is merely meant for the extra number of forms to display. You can add more f...
In 8e6a08e: Refs #26142 -- Documented that Formset's extra=0 doesn't prevent creating objects. In 204d31c: [1.9.x] Refs #26142 -- Documented that Formset's extra=0 doesn't prevent creating objects. Backport of 8e6a08e937272f088902cdbec65a9f2e919783bf from master Doesn't max_num already allow this? Testing on master, if...
2021-08-01T21:24:36Z
<patch> diff --git a/django/forms/models.py b/django/forms/models.py --- a/django/forms/models.py +++ b/django/forms/models.py @@ -676,7 +676,10 @@ def save_m2m(): for form in self.saved_forms: form.save_m2m() self.save_m2m = save_m2m - return self.save_existing...
diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py --- a/tests/model_formsets/tests.py +++ b/tests/model_formsets/tests.py @@ -1771,6 +1771,73 @@ def test_initial_form_count_empty_data(self): formset = AuthorFormSet({}) self.assertEqual(formset.initial_form_count(), 0) + d...
4.1
["test_edit_only (model_formsets.tests.ModelFormsetTest)", "test_edit_only_inlineformset_factory (model_formsets.tests.ModelFormsetTest)", "test_edit_only_object_outside_of_queryset (model_formsets.tests.ModelFormsetTest)"]
["Make sure that an add form that is filled out, but marked for deletion", "Make sure that a change form that is filled out, but marked for deletion", "test_deletion (model_formsets.tests.DeletionTests)", "test_outdated_deletion (model_formsets.tests.DeletionTests)", "test_callable_defaults (model_formsets.tests.ModelF...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-14752
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Refactor AutocompleteJsonView to support extra fields in autocomplete response Description (last modified by mrts) Adding data attributes to items in ordinary non-autocomplete foreign key fields that us...
django/django
b64db05b9cedd96905d637a2d824cbbf428e40e7
Refactor AutocompleteJsonView to support extra fields in autocomplete response Description (last modified by mrts) Adding data attributes to items in ordinary non-autocomplete foreign key fields that use forms.widgets.Select-based widgets is relatively easy. This enables powerful and dynamic admin site customiz...
Makes sense to me.
2021-08-07T16:34:32Z
<patch> diff --git a/django/contrib/admin/views/autocomplete.py b/django/contrib/admin/views/autocomplete.py --- a/django/contrib/admin/views/autocomplete.py +++ b/django/contrib/admin/views/autocomplete.py @@ -11,7 +11,8 @@ class AutocompleteJsonView(BaseListView): def get(self, request, *args, **kwargs): ...
diff --git a/tests/admin_views/test_autocomplete_view.py b/tests/admin_views/test_autocomplete_view.py --- a/tests/admin_views/test_autocomplete_view.py +++ b/tests/admin_views/test_autocomplete_view.py @@ -1,3 +1,4 @@ +import datetime import json from contextlib import contextmanager @@ -293,6 +294,29 @@ class PKO...
4.0
["test_serialize_result (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)"]
["test_custom_to_field (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_custom_to_field_custom_pk (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_custom_to_field_permission_denied (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_field_does_not_allowed (...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14765
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ProjectState.__init__() can assume its real_apps argument is a set Description ​PR #14760 made all calls to ProjectState.__init__() pass real_apps as a set. In ​ProjectState.__init__() now, then, instead of c...
django/django
4e8121e8e42a24acc3565851c9ef50ca8322b15c
ProjectState.__init__() can assume its real_apps argument is a set Description ​PR #14760 made all calls to ProjectState.__init__() pass real_apps as a set. In ​ProjectState.__init__() now, then, instead of checking that real_apps is a set and converting it to a set if not, it can just assert that it's a set when non...
Hey Chris. I'm a bit Meh about the suggestion here but I'll accept so you can make the PR for review. (If the others like it...) ...part of Django's internal API I'm forever amazed what parts of Django folks out there are using. Perhaps not this. :) Thanks.
2021-08-12T05:59:11Z
<patch> diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -91,10 +91,11 @@ class ProjectState: def __init__(self, models=None, real_apps=None): self.models = models or {} # Apps to include from mai...
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -924,6 +924,10 @@ class Meta: 1, ) + def test_real_apps_non_set(self): + with self.assertRaises(AssertionError): + Projec...
4.0
["test_real_apps_non_set (migrations.test_state.StateTests)"]
["test_abstract_model_children_inherit_indexes (migrations.test_state.ModelStateTests)", "test_bound_field_sanity_check (migrations.test_state.ModelStateTests)", "Tests making a ProjectState from an Apps with a swappable model", "A swappable model inheriting from a hierarchy:", "Tests making a ProjectState from unused ...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14771
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Auto-reloader should pass -X options (for cpython implementation) Description Windows OS $ winpty python -m django startproject my_project $ cd my_project/ $ winpty python -m django startapp my_app $ vi my_ap...
django/django
4884a87e022056eda10534c13d74e49b8cdda632
Auto-reloader should pass -X options (for cpython implementation) Description Windows OS $ winpty python -m django startproject my_project $ cd my_project/ $ winpty python -m django startapp my_app $ vi my_app/apps.py # demo for xoptions ... $ cat -n my_app/apps.py 1 from django.apps import AppConfig 2 3 class ...
2021-08-15T07:26:17Z
<patch> diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -220,6 +220,11 @@ def get_child_arguments(): py_script = Path(sys.argv[0]) args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + if sys.implementat...
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -170,6 +170,7 @@ class TestChildArguments(SimpleTestCase): @mock.patch.dict(sys.modules, {'__main__': django.__main__}) @mock.patch(...
4.1
["test_xoptions (utils_tests.test_autoreload.TestChildArguments)"]
["test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_ex...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-14787
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> method_decorator() should preserve wrapper assignments Description the function that is passed to the decorator is a partial object and does not have any of the attributes expected from a function i.e. __name...
django/django
004b4620f6f4ad87261e149898940f2dcd5757ef
method_decorator() should preserve wrapper assignments Description the function that is passed to the decorator is a partial object and does not have any of the attributes expected from a function i.e. __name__, __module__ etc... consider the following case def logger(func): @wraps(func) def inner(*args, **kwargs):...
2021-08-23T12:59:59Z
<patch> diff --git a/django/utils/decorators.py b/django/utils/decorators.py --- a/django/utils/decorators.py +++ b/django/utils/decorators.py @@ -37,7 +37,7 @@ def _wrapper(self, *args, **kwargs): # 'self' argument, but it's a closure over self so it can call # 'func'. Also, wrap method.__get__() in ...
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py --- a/tests/decorators/tests.py +++ b/tests/decorators/tests.py @@ -425,6 +425,29 @@ class Test: def __module__(cls): return "tests" + def test_wrapper_assignments(self): + """@method_decorator preserves...
4.1
["@method_decorator preserves wrapper assignments."]
["test_cache_control_decorator_http_request (decorators.tests.CacheControlDecoratorTest)", "Ensures @xframe_options_deny properly sets the X-Frame-Options header.", "Ensures @xframe_options_exempt properly instructs the", "Ensures @xframe_options_sameorigin properly sets the X-Frame-Options", "Built-in decorators set c...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-14792
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Reverse time zone conversion in Trunc()/Extract() database functions. Description When using a time zone of "Etc/GMT-10" (or similar) for a Trunc class tzinfo, it appears there's a different behavior as of Dj...
django/django
d89f976bddb49fb168334960acc8979c3de991fa
Reverse time zone conversion in Trunc()/Extract() database functions. Description When using a time zone of "Etc/GMT-10" (or similar) for a Trunc class tzinfo, it appears there's a different behavior as of Django 3.2 in the resulting database query. I think it's due to a change in the return value of timezone._get_ti...
Thanks for the report. Regression in 10d126198434810529e0220b0c6896ed64ca0e88. Reproduced at 4fe3774c729f3fd5105b3001fe69a70bdca95ac3. This problem is also affecting MySQL, the timezone "Etc/GMT-10" is returning "-10" instead of "-10:00". #33037
2021-08-24T09:25:15Z
<patch> diff --git a/django/utils/timezone.py b/django/utils/timezone.py --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -72,8 +72,11 @@ def get_current_timezone_name(): def _get_timezone_name(timezone): - """Return the name of ``timezone``.""" - return str(timezone) + """ + Return the...
diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py --- a/tests/utils_tests/test_timezone.py +++ b/tests/utils_tests/test_timezone.py @@ -260,6 +260,31 @@ def test_make_aware_zoneinfo_non_existent(self): self.assertEqual(std.utcoffset(), datetime.timedelta(hours=1)) se...
4.0
["The _get_timezone_name() helper must return the offset for fixed offset", "test_is_aware (utils_tests.test_timezone.TimezoneTests)"]
["test_activate_invalid_timezone (utils_tests.test_timezone.TimezoneTests)", "test_fixedoffset_negative_timedelta (utils_tests.test_timezone.TimezoneTests)", "test_fixedoffset_timedelta (utils_tests.test_timezone.TimezoneTests)", "test_get_default_timezone (utils_tests.test_timezone.TimezoneTests)", "test_get_default_t...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14855
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Wrong URL generated by get_admin_url for readonly field in custom Admin Site Description When a model containing a ForeignKey field is viewed (or edited) in a custom Admin Site, and that ForeignKey field is l...
django/django
475cffd1d64c690cdad16ede4d5e81985738ceb4
Wrong URL generated by get_admin_url for readonly field in custom Admin Site Description When a model containing a ForeignKey field is viewed (or edited) in a custom Admin Site, and that ForeignKey field is listed in readonly_fields, the url generated for the link is /admin/... instead of /custom-admin/.... This appe...
Hey Ken, yes seems right. Good spot. Looks like this should have been part of b79088306513d5ed76d31ac40ab3c15f858946ea for #31181 (which was Django 3.2) ​here. However, I don't know if there are any side effects and I have not yet run the full suite of tests on this. Mostly looking for feedback whether I'm on the right...
2021-09-14T01:27:01Z
<patch> diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -209,7 +209,11 @@ def get_admin_url(self, remote_field, remote_obj): remote_field.model._meta.model_name, ) try: - ...
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -1142,6 +1142,8 @@ def get_formsets_with_inlines(self, request, obj=None): raw_id_fields=['parent'], ) site2.register(Person, save_as_continue=False) +site2.register(ReadOnlyR...
4.0
["test_readonly_foreignkey_links_custom_admin_site (admin_views.tests.ReadonlyTest)"]
["test_explicitly_provided_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_implicitly_generated_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_should_be_able_to_edit_related_objects_on_add_view (admin_views.tests.AdminCustomSaveRelatedTests)", "test_should_be_able_to_edit_related_ob...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django__django-14915
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ModelChoiceIteratorValue is not hashable. Description Recently I migrated from Django 3.0 to Django 3.1. In my code, I add custom data-* attributes to the select widget options. After the upgrade some of thos...
django/django
903aaa35e5ceaa33bfc9b19b7f6da65ce5a91dd4
ModelChoiceIteratorValue is not hashable. Description Recently I migrated from Django 3.0 to Django 3.1. In my code, I add custom data-* attributes to the select widget options. After the upgrade some of those options broke. Error is {TypeError}unhashable type: 'ModelChoiceIteratorValue'. Example (this one breaks): ...
Thanks for the ticket. Agreed, we could make ModelChoiceIteratorValue hashable by adding: def __hash__(self): return hash(self.value) For now you can use value.value as ​documented in the "Backwards incompatible changes in 3.1" section. Would you like to prepare a patch? Replying to Mariusz Felisiak: Thanks for the tic...
2021-09-29T22:00:15Z
<patch> diff --git a/django/forms/models.py b/django/forms/models.py --- a/django/forms/models.py +++ b/django/forms/models.py @@ -1166,6 +1166,9 @@ def __init__(self, value, instance): def __str__(self): return str(self.value) + def __hash__(self): + return hash(self.value) + def __eq__(...
diff --git a/tests/model_forms/test_modelchoicefield.py b/tests/model_forms/test_modelchoicefield.py --- a/tests/model_forms/test_modelchoicefield.py +++ b/tests/model_forms/test_modelchoicefield.py @@ -2,7 +2,7 @@ from django import forms from django.core.exceptions import ValidationError -from django.forms.models...
4.1
["test_choice_value_hash (model_forms.test_modelchoicefield.ModelChoiceFieldTests)"]
["test_basics (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_choice_iterator_passes_model_to_widget (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_choices (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_choices_bool (model_forms.test_modelchoicefield.ModelChoiceFi...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-14999
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> RenameModel with db_table should be a noop. Description A RenameModel operation that already has db_table defined must be a noop. In Postgres, it drops and recreates foreign key constraints. In sqlite it recr...
django/django
a754b82dac511475b6276039471ccd17cc64aeb8
RenameModel with db_table should be a noop. Description A RenameModel operation that already has db_table defined must be a noop. In Postgres, it drops and recreates foreign key constraints. In sqlite it recreates the table (as expected for a table renaming).
2021-10-16T09:31:21Z
<patch> 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 @@ -320,12 +320,13 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state): new_model...
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 @@ -793,6 +793,28 @@ def test_rename_model_with_m2m(self): self.assertEqual(Rider.objects.count(), 2) self.assertEqual(Pony._meta.g...
4.1
["test_rename_model_with_db_table_noop (migrations.test_operations.OperationTests)"]
["test_references_model_mixin (migrations.test_operations.TestCreateModel)", "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.Fiel...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15022
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Unnecessary joins in admin changelist query Description Django 1.2.5 Models: class Client(models.Model): name = models.CharField(_('name'), max_length=256) name2 = models.CharField(_('unofficial or obsolete...
django/django
e1d673c373a7d032060872b690a92fc95496612e
Unnecessary joins in admin changelist query Description Django 1.2.5 Models: class Client(models.Model): name = models.CharField(_('name'), max_length=256) name2 = models.CharField(_('unofficial or obsolete name'), max_length=256, blank=True, null=True) contact_person = models.CharField(_('contact person'), max_le...
patch has been made from Mercurial repository This seems related to #13902 and #15819. Are you able to test if this gets fixed by using Django 1.3 or trunk? Looking at the code, the part that is modified by the patch is not modified in current trunk. The problematic pattern is still there: for bit in self.query.split()...
2021-10-24T17:48:28Z
<patch> 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 @@ -1031,6 +1031,7 @@ def construct_search(field_name): if search_fields and search_term: orm_lookups = [construct_search(str(search_fi...
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py --- a/tests/admin_changelist/admin.py +++ b/tests/admin_changelist/admin.py @@ -36,6 +36,12 @@ class ParentAdmin(admin.ModelAdmin): list_select_related = ['child'] +class ParentAdminTwoSearchFields(admin.ModelAdmin): + list_filte...
4.1
["test_many_search_terms (admin_changelist.tests.ChangeListTests)", "All rows containing each of the searched words are returned, where each", "Searches over multi-valued relationships return rows from related"]
["{% 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)"...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15037
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Foreign key to a specific field is not handled in inspectdb Description (last modified by Tim Graham) if you have a DB like that CREATE TABLE foo ( id serial primary key, other_id int UNIQUE); CREATE TA...
django/django
dab48b7482295956973879d15bfd4d3bb0718772
Foreign key to a specific field is not handled in inspectdb Description (last modified by Tim Graham) if you have a DB like that CREATE TABLE foo ( id serial primary key, other_id int UNIQUE); CREATE TABLE bar ( id serial primary key, other_id int, constraint myconst FOREIGN KEY(other_id) references foo(oth...
simple patch to handle FK to non pk field. it seems I cannot reproduce outside of my own code... I will check it!
2021-10-30T15:21:38Z
<patch> diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py --- a/django/core/management/commands/inspectdb.py +++ b/django/core/management/commands/inspectdb.py @@ -116,13 +116,17 @@ def table2model(table_name): extra_params['unique'] = True...
diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py --- a/tests/inspectdb/models.py +++ b/tests/inspectdb/models.py @@ -21,6 +21,12 @@ class PeopleMoreData(models.Model): license = models.CharField(max_length=255) +class ForeignKeyToField(models.Model): + to_field_fk = models.ForeignKey( + ...
4.1
["test_foreign_key_to_field (inspectdb.tests.InspectDBTestCase)"]
["inspectdb --include-views creates models for database views.", "test_attribute_name_not_python_keyword (inspectdb.tests.InspectDBTestCase)", "test_char_field_db_collation (inspectdb.tests.InspectDBTestCase)", "Introspection of column names consist/start with digits (#16536/#17676)", "Test introspection of various Dja...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15098
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Internationalisation didn't support language locale containing both script and region. Description The i18n_patterns didn't work with locale contains both script and region, like en-latn-us. Given settings.py...
django/django
2c7846d992ca512d36a73f518205015c88ed088c
Internationalisation didn't support language locale containing both script and region. Description The i18n_patterns didn't work with locale contains both script and region, like en-latn-us. Given settings.py LANGUAGE_CODE = 'en-us' LANGUAGES = [ ('en-us', "English"), ('en-latn-us', "Latin English"), ('en-Latn-US'...
What's the use case of using en-latn-us? Replying to Claude Paroz: What's the use case of using en-latn-us? Our language, Taigi in Taiwan, is denoted by nan in ISO 639-3. nan denoted other languages which are different from Taigi although we are submitting the proposal for new language code this year. So that the langu...
2021-11-17T21:30:07Z
<patch> diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -43,7 +43,7 @@ re.IGNORECASE ) -language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+)?)(/|$)') +language_code_p...
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1593,22 +1593,41 @@ def test_get_supported_language_variant_null(self): @override_settings( LANGUAGES=[ ('en', 'English'), + ('en-latn-us', 'Latin English'), + ...
4.1
["test_get_language_from_path_real (i18n.tests.MiscTests)", "test_get_supported_language_variant_null (i18n.tests.MiscTests)"]
["OSError is raised if the default language is unparseable.", "test_ignores_non_mo_files (i18n.tests.TranslationFileChangedTests)", "test_resets_cache_with_mo_files (i18n.tests.TranslationFileChangedTests)", "test_round_away_from_one (i18n.tests.UtilsTests)", "test_lazy (i18n.tests.TestModels)", "test_safestr (i18n.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15103
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Make the element_id argument of json_script optional Description I recently had a use-case where I wanted to use json_script but I didn't need any id for it (I was including the <script> inside a <template> s...
django/django
dd528cb2cefc0db8b91a7ff0a2bc87305b976597
Make the element_id argument of json_script optional Description I recently had a use-case where I wanted to use json_script but I didn't need any id for it (I was including the <script> inside a <template> so I didn't need an id to refer to it). I can't see any reason (security or otherwise) for the id to be require...
2021-11-19T15:57:54Z
<patch> diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -83,10 +83,10 @@ def escapejs_filter(value): @register.filter(is_safe=True) -def json_script(value, element_id): +def json_script(value, elem...
diff --git a/tests/template_tests/filter_tests/test_json_script.py b/tests/template_tests/filter_tests/test_json_script.py --- a/tests/template_tests/filter_tests/test_json_script.py +++ b/tests/template_tests/filter_tests/test_json_script.py @@ -17,3 +17,8 @@ def test_basic(self): '{"a": "testing\\r\\njso...
4.1
["test_without_id (template_tests.filter_tests.test_json_script.JsonScriptTests)", "test_json_script_without_id (utils_tests.test_html.TestUtilsHtml)"]
["test_basic (template_tests.filter_tests.test_json_script.JsonScriptTests)", "test_conditional_escape (utils_tests.test_html.TestUtilsHtml)", "test_escape (utils_tests.test_html.TestUtilsHtml)", "test_escapejs (utils_tests.test_html.TestUtilsHtml)", "test_format_html (utils_tests.test_html.TestUtilsHtml)", "test_html_...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15104
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> KeyError with migration autodetector and FK field with hardcoded reference Description Hi, I encountered this issue on an old Django project (probably 10 years old) with tons of models and probably a lot of q...
django/django
a7e7043c8746933dafce652507d3b821801cdc7d
KeyError with migration autodetector and FK field with hardcoded reference Description Hi, I encountered this issue on an old Django project (probably 10 years old) with tons of models and probably a lot of questionable design decisions. The symptom is that running our test suite in verbose mode doesn't work: $ pytho...
2021-11-19T20:46:58Z
<patch> 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 @@ -96,7 +96,7 @@ def only_relation_agnostic_fields(self, fields): for name, field in sorted(fields.items()): decon...
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 @@ -2834,6 +2834,28 @@ def test_parse_number(self): expected_number, ) + def test_add_custom_fk_wi...
4.1
["test_add_custom_fk_with_hardcoded_to (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...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15127
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> LEVEL_TAGS not updated when using @override_settings Description When reading messages inside tests, new message tags created using @override_settings is not updated. That causes the django.contrib.messages.s...
django/django
9a6e2df3a8f01ea761529bec48e5a8dc0ea9575b
LEVEL_TAGS not updated when using @override_settings Description When reading messages inside tests, new message tags created using @override_settings is not updated. That causes the django.contrib.messages.storage.base.Message.level_tag property results to be an empty string and not know the new tags.
If you aren't planning to provide a patch (with a test), could you provide some minimal code that demonstrates the issue? LEVEL_TAGS is a constant defined in the django.contrib.messages.storage.base module that's why it needs to be updated after changing MESSAGE_TAGS (see #16574 and ​override_settings_tags() hook). It ...
2021-11-25T13:14:38Z
<patch> diff --git a/django/contrib/messages/apps.py b/django/contrib/messages/apps.py --- a/django/contrib/messages/apps.py +++ b/django/contrib/messages/apps.py @@ -1,7 +1,18 @@ from django.apps import AppConfig +from django.contrib.messages.storage import base +from django.contrib.messages.utils import get_level_ta...
diff --git a/tests/messages_tests/base.py b/tests/messages_tests/base.py --- a/tests/messages_tests/base.py +++ b/tests/messages_tests/base.py @@ -1,7 +1,7 @@ -from django.contrib.messages import constants, get_level, set_level, utils +from django.contrib.messages import constants, get_level, set_level from django.con...
4.1
["test_override_settings_level_tags (messages_tests.tests.TestLevelTags)"]
["test_eq (messages_tests.tests.MessageTests)"]
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15128
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Query.change_aliases raises an AssertionError Description Python Version: 3.9.2 Django Version: 2.2.24, 3.2.9 (reproduced using two different versions) Code to Reproduce # models.py from django.db import mod...
django/django
cb383753c0e0eb52306e1024d32a782549c27e61
Query.change_aliases raises an AssertionError Description Python Version: 3.9.2 Django Version: 2.2.24, 3.2.9 (reproduced using two different versions) Code to Reproduce # models.py from django.db import models class Foo(models.Model): qux = models.ForeignKey("app.Qux", on_delete=models.CASCADE, related_name="foos"...
Thanks for the report. Reproduced at b8c0b22f2f0f8ce664642332d6d872f300c662b4. Vishal Pandey, if you're looking for pointers on how to resolve the issue I think I have a pretty good understanding of the problem. The root cause is that both queries happen to share the same alias_prefix; the letter used generate aliases ...
2021-11-25T15:50:24Z
<patch> 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 @@ -572,6 +572,15 @@ def combine(self, rhs, connector): if self.distinct_fields != rhs.distinct_fields: raise TypeError('Cannot combine queries...
diff --git a/tests/queries/models.py b/tests/queries/models.py --- a/tests/queries/models.py +++ b/tests/queries/models.py @@ -613,13 +613,14 @@ def __str__(self): class BaseUser(models.Model): - pass + annotation = models.ForeignKey(Annotation, models.CASCADE, null=True, blank=True) class Task(models.M...
4.1
["test_conflicting_aliases_during_combine (queries.tests.QuerySetBitwiseOperationTests)"]
["test_ticket14729 (queries.tests.RawQueriesTests)", "test_datetimes_invalid_field (queries.tests.Queries3Tests)", "test_ticket22023 (queries.tests.Queries3Tests)", "test_ticket7107 (queries.tests.Queries3Tests)", "test_21001 (queries.tests.EmptyStringsAsNullTest)", "test_direct_exclude (queries.tests.EmptyStringsAsNul...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15161
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Use simplified paths for deconstruct of expressions Description Previously F() deconstructed to: django.db.models.expressions.F(). But since it can also be imported from django.db.models, ​PR #14047 changed i...
django/django
96e7ff5e9ff6362d9a886545869ce4496ca4b0fb
Use simplified paths for deconstruct of expressions Description Previously F() deconstructed to: django.db.models.expressions.F(). But since it can also be imported from django.db.models, ​PR #14047 changed it to deconstruct to django.db.models.F(). This simplifies generated migration code where it will be referenced...
I would like to give this a try if someone can guide me on how to proceed with this problem. I don't think much more guidance can be given particular to this ticket. Did you see the example PR? Have you read the contributing guidelines and the first patch tutorial?
2021-12-06T09:06:13Z
<patch> 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 @@ -651,6 +651,7 @@ def relabeled_clone(self, relabels): return self +@deconstructible(path='django.db.models.Func') class Func(SQLiteNumericMi...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1763,14 +1763,14 @@ def test_update_UUIDField_using_Value(self): def test_deconstruct(self): value = Value('name') path, args, kwargs = value.deconstruct() - ...
4.1
["test_deconstruct (expressions.tests.ValueTests)", "test_deconstruct_output_field (expressions.tests.ValueTests)", "test_serialize_complex_func_index (migrations.test_writer.WriterTests)"]
["test_equal (expressions.tests.OrderByTests)", "test_hash (expressions.tests.OrderByTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTests)", "test_or (expressions.tests.CombinableTests)", "test_reversed_and (expressions.tests.CombinableTests)", "test_reversed_or (ex...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15252
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> MigrationRecorder does not obey db_router allow_migrate rules Description Hi, We have a multi-db setup. We have one connection that is for the django project, and several connections that talk to other dbs fo...
django/django
361bb8f786f112ee275be136795c0b1ecefff928
MigrationRecorder does not obey db_router allow_migrate rules Description Hi, We have a multi-db setup. We have one connection that is for the django project, and several connections that talk to other dbs for information (ie models with managed = False). Django should only create tables in the first connection, neve...
I don't think you've implemented your router correctly, but I'd need to check the router code to see if it's called multiple times (num_dbs*num_models) to be sure. This is how we implement our routers for allow_migrate: def allow_migrate(self, db, model): if db == 'other': return model._meta.app_label == 'legacy_app' #...
2021-12-28T15:51:06Z
<patch> diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py --- a/django/db/migrations/executor.py +++ b/django/db/migrations/executor.py @@ -96,8 +96,12 @@ def migrate(self, targets, plan=None, state=None, fake=False, fake_initial=False (un)applied and in a second step run all the...
diff --git a/tests/backends/base/test_creation.py b/tests/backends/base/test_creation.py --- a/tests/backends/base/test_creation.py +++ b/tests/backends/base/test_creation.py @@ -57,12 +57,12 @@ def test_custom_test_name_with_test_prefix(self): @mock.patch.object(connection, 'ensure_connection') @mock.patch.object(co...
4.1
["test_migrate_test_setting_false_ensure_schema (backends.base.test_creation.TestDbCreationTests)", "The django_migrations table is not created if there are no migrations"]
["test_mark_expected_failures_and_skips (backends.base.test_creation.TestMarkTests)", "test_custom_test_name (backends.base.test_creation.TestDbSignatureTests)", "test_custom_test_name_with_test_prefix (backends.base.test_creation.TestDbSignatureTests)", "test_default_name (backends.base.test_creation.TestDbSignatureTe...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15268
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Optimize multiple AlterFooTogether operations into one Description Hi, In #31503 we split the AlterFooTogether (AlterUniqueTogether and AlterIndexTogether) operations into two types of operations. First, a mi...
django/django
0ab58c120939093fea90822f376e1866fc714d1f
Optimize multiple AlterFooTogether operations into one Description Hi, In #31503 we split the AlterFooTogether (AlterUniqueTogether and AlterIndexTogether) operations into two types of operations. First, a migration will have operations to remove constraints, and then other operations adds the new constraints. This a...
2022-01-01T09:57:13Z
<patch> 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 @@ -34,9 +34,12 @@ def references_model(self, name, app_label): def reduce(self, operation, app_label): ...
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 @@ -1573,21 +1573,13 @@ def test_foo_together_ordering(self): self.assertOperationTypes(changes, 'otherapp', 0, [ 'Alte...
4.1
["index/unique_together also triggers on ordering changes.", "Removed fields will be removed after updating index/unique_together.", "Fields are renamed before updating index/unique_together."]
["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...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15277
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Micro-optimisation for Value._resolve_output_field (by modifying CharField.__init__) Description Currently, when you do something like annotate(x=Value('test')) that will eventually probably call down into Va...
django/django
30613d6a748fce18919ff8b0da166d9fda2ed9bc
Micro-optimisation for Value._resolve_output_field (by modifying CharField.__init__) Description Currently, when you do something like annotate(x=Value('test')) that will eventually probably call down into Value._resolve_output_field() and run the following code: if isinstance(self.value, str): return fields.CharFie...
All tests passed in CI, PR is ​https://github.com/django/django/pull/15277 Force pushing a revised commit which includes a test case that errors without the change, for regression purposes.
2022-01-03T12:14:06Z
<patch> diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -1010,7 +1010,8 @@ class CharField(Field): def __init__(self, *args, db_collation=None, **kwargs): super().__init__(*args, *...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1852,6 +1852,30 @@ def test_resolve_output_field_failure(self): with self.assertRaisesMessage(FieldError, msg): Value(object()).output_field + def test_ou...
4.1
["The output field for a given Value doesn't get cleaned & validated,", "test_raise_empty_expressionlist (expressions.tests.ValueTests)"]
["test_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_non_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTests)", "test_or (expressions.tests.CombinableTests)", "test_reversed_and (expressions.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15278
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Adding nullable OneToOneField crashes on SQLite. Description This new sqlite3 error has cropped up between building django-oauth-toolkit between Django 4.0 and main branch for migrations.AddField of a OneToOn...
django/django
0ab58c120939093fea90822f376e1866fc714d1f
Adding nullable OneToOneField crashes on SQLite. Description This new sqlite3 error has cropped up between building django-oauth-toolkit between Django 4.0 and main branch for migrations.AddField of a OneToOneField (see ​https://github.com/jazzband/django-oauth-toolkit/issues/1064): self = <django.db.backends.sqlite3...
Thanks for the report! Regression in 2f73e5406d54cb8945e187eff302a3a3373350be.
2022-01-03T20:01:32Z
<patch> diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py --- a/django/db/backends/sqlite3/schema.py +++ b/django/db/backends/sqlite3/schema.py @@ -324,10 +324,15 @@ def delete_model(self, model, handle_autom2m=True): def add_field(self, model, field): """Create a ...
diff --git a/tests/schema/tests.py b/tests/schema/tests.py --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -624,6 +624,18 @@ def get_prep_value(self, value): # Make sure the values were transformed correctly self.assertEqual(Author.objects.extra(where=["thing = 1"]).count(), 2) + def t...
4.1
["test_add_field_o2o_nullable (schema.tests.SchemaTests)"]
["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15280
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Deferred fields incorrect when following prefetches back to the "parent" object Description Given the following models: class User(models.Model): email = models.EmailField() kind = models.CharField( max_l...
django/django
973fa566521037ac140dcece73fceae50ee522f1
Deferred fields incorrect when following prefetches back to the "parent" object Description Given the following models: class User(models.Model): email = models.EmailField() kind = models.CharField( max_length=10, choices=[("ADMIN", "Admin"), ("REGULAR", "Regular")] ) class Profile(models.Model): full_name = mo...
When using prefetch_related the retrieved objects are assigned their origin's foreign object so in this case the inner prefetch is performed but entirely discarded because it's the outer's query user (the ones with only email) that are assigned to the prefetched profiles. I guess we should either change the current beh...
2022-01-04T11:16:35Z
<patch> 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 @@ -646,8 +646,9 @@ def get_prefetch_queryset(self, instances, queryset=None): # Sin...
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 @@ -1614,3 +1614,29 @@ def test_retrieves_results_from_prefetched_objects_cache(self): with self.assertNumQueries(4): # AuthorWithAge -> Author...
4.1
["The prefetched relationship is used rather than populating the reverse"]
["test_bug (prefetch_related.tests.Ticket21410Tests)", "test_bug (prefetch_related.tests.Ticket19607Tests)", "test_m2m_then_m2m (prefetch_related.tests.DefaultManagerTests)", "When intermediary results are prefetched without a destination", "test_bug (prefetch_related.tests.Ticket21760Tests)", "test_foreignkey (prefetc...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15315
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Model Field.__hash__() should be immutable. Description Field.__hash__ changes value when a field is assigned to a model class. This code crashes with an AssertionError: from django.db import models f = model...
django/django
652c68ffeebd510a6f59e1b56b3e007d07683ad8
Model Field.__hash__() should be immutable. Description Field.__hash__ changes value when a field is assigned to a model class. This code crashes with an AssertionError: from django.db import models f = models.CharField(max_length=200) d = {f: 1} class Book(models.Model): title = f assert f in d The bug was introduc...
2022-01-13T18:51:58Z
<patch> diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -542,11 +542,7 @@ def __lt__(self, other): return NotImplemented def __hash__(self): - return hash(( - s...
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py --- a/tests/model_fields/tests.py +++ b/tests/model_fields/tests.py @@ -128,9 +128,14 @@ class InheritAbstractModel2(AbstractModel): self.assertLess(abstract_model_field, inherit2_model_field) self.assertLess(inherit1_model_field, ...
4.1
["test_hash_immutability (model_fields.tests.BasicFieldTests)"]
["test_check (model_fields.tests.ChoicesTests)", "test_choices (model_fields.tests.ChoicesTests)", "test_flatchoices (model_fields.tests.ChoicesTests)", "test_formfield (model_fields.tests.ChoicesTests)", "test_invalid_choice (model_fields.tests.ChoicesTests)", "test_blank_in_choices (model_fields.tests.GetChoicesTests...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15368
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> bulk_update() does not work with plain F('...') expressions. Description Repro: assign plain F(...) to some model instance field save with bulk_update Example: Code highlighting: >>> from exampleapp.models im...
django/django
e972620ada4f9ed7bc57f28e133e85c85b0a7b20
bulk_update() does not work with plain F('...') expressions. Description Repro: assign plain F(...) to some model instance field save with bulk_update Example: Code highlighting: >>> from exampleapp.models import SelfRef >>> o = SelfRef.objects.all().first() >>> o.c8 = F('name') # model has char fields 'c8' and 'name...
Thanks for the report. Agreed, we should check resolve_expression like elsewhere. Would you like to provide a patch? Sure, can do a patch. Is this worth to add a test case as well?
2022-01-27T13:44:35Z
<patch> 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 @@ -17,7 +17,7 @@ from django.db.models import AutoField, DateField, DateTimeField, sql from django.db.models.constants import LOOKUP_SEP, OnConflict from django.db.models.deleti...
diff --git a/tests/queries/test_bulk_update.py b/tests/queries/test_bulk_update.py --- a/tests/queries/test_bulk_update.py +++ b/tests/queries/test_bulk_update.py @@ -211,6 +211,16 @@ def test_field_references(self): Number.objects.bulk_update(numbers, ['num']) self.assertCountEqual(Number.objects.fil...
4.1
["test_f_expression (queries.test_bulk_update.BulkUpdateTests)"]
["test_batch_size (queries.test_bulk_update.BulkUpdateNoteTests)", "test_foreign_keys_do_not_lookup (queries.test_bulk_update.BulkUpdateNoteTests)", "test_functions (queries.test_bulk_update.BulkUpdateNoteTests)", "test_multiple_fields (queries.test_bulk_update.BulkUpdateNoteTests)", "test_set_field_to_null (queries.te...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15375
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> aggregate() with 'default' after annotate() crashes. Description I saw this on a PostgreSQL project and reproduced it with SQLite. Django 4.0.1. Annotate (anything) then aggregate works fine: $ ./manage.py sh...
django/django
beb7ddbcee03270e833b2f74927ccfc8027aa693
aggregate() with 'default' after annotate() crashes. Description I saw this on a PostgreSQL project and reproduced it with SQLite. Django 4.0.1. Annotate (anything) then aggregate works fine: $ ./manage.py shell Python 3.10.2 (main, Jan 21 2022, 19:45:54) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits...
Thanks for the report! Would you like to prepare a patch? If not, you can assign it me as 4.0.2 will be issued on Tuesday. I have had a quick look but I got a bit lost. Aggregate.default generates a Coalesce internally so it seems a little lower level. If you have the capacity that would be appreciated. Replying to Ada...
2022-01-28T14:48:03Z
<patch> diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py --- a/django/db/models/aggregates.py +++ b/django/db/models/aggregates.py @@ -65,7 +65,9 @@ def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize if hasattr(default, 'resolve_expression'): ...
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1630,6 +1630,18 @@ def test_aggregation_default_passed_another_aggregate(self): ) self.assertAlmostEqual(result['value'], Decimal('61.72'), places=2) + def te...
4.1
["test_aggregation_default_after_annotation (aggregation.tests.AggregateTestCase)"]
["test_add_implementation (aggregation.tests.AggregateTestCase)", "test_aggregate_alias (aggregation.tests.AggregateTestCase)", "test_aggregate_annotation (aggregation.tests.AggregateTestCase)", "test_aggregate_in_order_by (aggregation.tests.AggregateTestCase)", "test_aggregate_join_transform (aggregation.tests.Aggrega...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15380
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Migration autodetector crashes when renaming a model and field. Description Migration autodetector crashes when renaming a model and field in a single step: $ python manage.py makemigrations Did you rename th...
django/django
71e7c8e73712419626f1c2b6ec036e8559a2d667
Migration autodetector crashes when renaming a model and field. Description Migration autodetector crashes when renaming a model and field in a single step: $ python manage.py makemigrations Did you rename the test_one.MyModel model to MyModel2? [y/N] y Traceback (most recent call last): File "manage.py", line 22, i...
2022-01-31T19:44:44Z
<patch> 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 @@ -824,7 +824,7 @@ def generate_renamed_fields(self): for app_label, model_name, field_name in sorted(self.new_field_keys - sel...
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 @@ -1049,6 +1049,26 @@ def test_rename_related_field_preserved_db_column(self): new_name='renamed_foo', ) + def te...
4.1
["test_rename_field_with_renamed_model (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...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15382
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> filter on exists-subquery with empty queryset removes whole WHERE block Description (last modified by Tobias Bengfort) >>> qs = MyModel.objects.filter(~models.Exists(MyModel.objects.none()), name='test'...
django/django
770d3e6a4ce8e0a91a9e27156036c1985e74d4a3
filter on exists-subquery with empty queryset removes whole WHERE block Description (last modified by Tobias Bengfort) >>> qs = MyModel.objects.filter(~models.Exists(MyModel.objects.none()), name='test') >>> qs <QuerySet []> >>> print(qs.query) EmptyResultSet With django-debug-toolbar I can still see the query,...
I think that this is an issue with Exists.as_sql when self.invert is True. Since Exists encapsulate its negation logic (see __invert__) it should catch EmptyResultSet when raised by its super() call in as_sql and return an always true predicate (e.g. 1=1). Does the following patch address your issue? django/db/models/e...
2022-02-01T18:29:41Z
<patch> 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 @@ -1211,13 +1211,18 @@ def __invert__(self): def as_sql(self, compiler, connection, template=None, **extra_context): query = self.query.exis...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1905,6 +1905,13 @@ def test_optimizations(self): ) self.assertNotIn('ORDER BY', captured_sql) + def test_negated_empty_exists(self): + manager = Manage...
4.1
["test_negated_empty_exists (expressions.tests.ExistsTests)"]
["test_equal (expressions.tests.OrderByTests)", "test_hash (expressions.tests.OrderByTests)", "test_aggregates (expressions.tests.ReprTests)", "test_distinct_aggregates (expressions.tests.ReprTests)", "test_expressions (expressions.tests.ReprTests)", "test_filtered_aggregates (expressions.tests.ReprTests)", "test_funct...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15467
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> ModelAdmin with defined radio_fields override empty_label Description ModelAdmin drops my "empty_label" and set "default_empty_label". For example: class MyModelAdmin(ModelAdmin): radio_fields = 'myfield', ...
django/django
e0442a628eb480eac6a7888aed5a86f83499e299
ModelAdmin with defined radio_fields override empty_label Description ModelAdmin drops my "empty_label" and set "default_empty_label". For example: class MyModelAdmin(ModelAdmin): radio_fields = 'myfield', def formfield_for_foreignkey(self, db_field, *args, **kwargs): if db_field.name == 'myfield': kwargs['emp...
Agreed, empty_label from kwargs should take precedence over _('None'). I want to work on this to get familiarised with contributing process. Assigning this to me.
2022-02-27T03:00:31Z
<patch> 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 @@ -269,7 +269,9 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): "class": get_ul_class(self.radio_fields[db_fiel...
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -21,6 +21,7 @@ CharField, DateField, DateTimeField, + ForeignKey, ManyToManyField, UUIDField, ) @@ -141,6 +142,17 @@ def test_radio_fields_Foreig...
4.1
["test_radio_fields_foreignkey_formfield_overrides_empty_label (admin_widgets.tests.AdminFormfieldForDBFieldTests)"]
["test_CharField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_DateField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_DateTimeField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_EmailField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_FileField (admin_widgets.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15499
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Optimize CreateModel + AlterModelManagers to CreateModel Description During migration optimization, CreateModel + AlterModelOptions is reduced to just CreateModel, with the model options. Similarly, CreateMod...
django/django
d90e34c61b27fba2527834806639eebbcfab9631
Optimize CreateModel + AlterModelManagers to CreateModel Description During migration optimization, CreateModel + AlterModelOptions is reduced to just CreateModel, with the model options. Similarly, CreateModel + AlterModelManagers can become just CreateModel.
2022-03-10T22:32:35Z
<patch> 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 @@ -170,6 +170,19 @@ def reduce(self, operation, app_label): managers=self.managers, ...
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 @@ -129,6 +129,30 @@ def test_create_alter_model_options(self): ], ) + def test_create_alter_model_managers(self): + se...
4.1
["test_create_alter_model_managers (migrations.test_optimizer.OptimizerTests)"]
["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_owrt_model (migrations.test_optimizer.OptimizerTests)", "test_alter_alter_table_model (migrations....
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15503
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> has_key, has_keys, and has_any_keys JSONField() lookups don't handle numeric keys on SQLite, MySQL, and Oracle. Description (last modified by TheTerrasque) Problem When using models.​JSONField() ​has_ke...
django/django
859a87d873ce7152af73ab851653b4e1c3ffea4c
has_key, has_keys, and has_any_keys JSONField() lookups don't handle numeric keys on SQLite, MySQL, and Oracle. Description (last modified by TheTerrasque) Problem When using models.​JSONField() ​has_key lookup with numerical keys on SQLite database it fails to find the keys. Versions: Django: 4.0.3 Python: 3.9...
Duplicate of #30566, see comment. Not a duplicate of #30566 This is django's models.JSONField() not postgres extension JSONField It works as expected on Postgresql, the bug is on SQLite #30566 goes directly against comments for https://code.djangoproject.com/ticket/29504 If different behavior is expected on SQLite (or ...
2022-03-12T06:22:37Z
<patch> diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py --- a/django/db/models/fields/json.py +++ b/django/db/models/fields/json.py @@ -172,6 +172,10 @@ def as_sql(self, compiler, connection): class HasKeyLookup(PostgresOperatorLookup): logical_operator = None + def compile_jso...
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -576,6 +576,33 @@ def test_has_any_keys(self): [self.objs[3], self.objs[4], self.objs[6]], ) + def test_has_key_num...
4.1
["test_has_key_number (model_fields.test_jsonfield.TestQuerying)", "test_has_keys (model_fields.test_jsonfield.TestQuerying)"]
["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_custom_encoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_decoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_encoder (model_fields...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15525
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> loaddata fails on non-default database when natural keys uses foreign keys. Description (last modified by François Granade) I've got a one-to-many relationship between two models Book and Author, that d...
django/django
fbacaa58ffc5a62456ee68b90efa13957f761ce4
loaddata fails on non-default database when natural keys uses foreign keys. Description (last modified by François Granade) I've got a one-to-many relationship between two models Book and Author, that define a natural keys in both models. I'm loading some data from a fixture. It works in the default database, b...
Thanks for this report. I was able to fix the issue by specifying db before checking natural_key(): django/core/serializers/base.py diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index da85cb4b92..517d2cad85 100644 a b def build_instance(Model, data, db): 336336 and hasattr(default_manag...
2022-03-18T10:39:26Z
<patch> diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py --- a/django/core/serializers/base.py +++ b/django/core/serializers/base.py @@ -336,7 +336,9 @@ def build_instance(Model, data, db): and hasattr(default_manager, "get_by_natural_key") and hasattr(Model, "natural_key...
diff --git a/tests/backends/sqlite/test_features.py b/tests/backends/sqlite/test_features.py --- a/tests/backends/sqlite/test_features.py +++ b/tests/backends/sqlite/test_features.py @@ -10,8 +10,9 @@ def test_supports_json_field_operational_error(self): if hasattr(connection.features, "supports_json_field"): ...
4.1
["Natural keys with foreing keys in dependencies works in a multiple"]
["test_supports_json_field_operational_error (backends.sqlite.test_features.FeaturesTests)", "test_fixtures_loaded (fixtures_regress.tests.TestLoadFixtureFromOtherAppDirectory)", "M2M relations with explicit through models should NOT count as", "Circular M2M relations with explicit through models should be serializable...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15554
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Using multiple FilteredRelation with different filters but for same relation is ignored. Description (last modified by lind-marcus) I have a relation that ALWAYS have at least 1 entry with is_all=True a...
django/django
59ab3fd0e9e606d7f0f7ca26609c06ee679ece97
Using multiple FilteredRelation with different filters but for same relation is ignored. Description (last modified by lind-marcus) I have a relation that ALWAYS have at least 1 entry with is_all=True and then I have an optional entry that could have is_all=False but instead have zone set. I'm trying to use Fil...
Thanks for the report! A regression test: tests/filtered_relation/tests.py diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 790a90d9e2..1208ddde5f 100644 a b class FilteredRelationTests(TestCase): 211211 str(queryset.query), 212212 ) 213213 214 def test_multiple(self): 215 qs = ( 2...
2022-03-29T10:12:46Z
<patch> 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 @@ -1011,7 +1011,7 @@ def count_active_tables(self): """ return len([1 for count in self.alias_refcount.values() if count]) - def join(self, j...
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -211,6 +211,34 @@ def test_internal_queryset_alias_mapping(self): str(queryset.query), ) + def test_multiple(self): + qs = (...
4.1
["test_multiple (filtered_relation.tests.FilteredRelationTests)"]
["filtered_relation() not only improves performance but also creates", "test_aggregate (filtered_relation.tests.FilteredRelationAnalyticalAggregationTests)", "test_as_subquery (filtered_relation.tests.FilteredRelationTests)", "test_condition_deeper_relation_name (filtered_relation.tests.FilteredRelationTests)", "test_c...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15561
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> AlterField operation should be noop when adding/changing choices on SQLite. Description while writing a test case for #33470 i found that for sqlite, even a seemingly db-transparent change like adding choices...
django/django
6991880109e35c879b71b7d9d9c154baeec12b89
AlterField operation should be noop when adding/changing choices on SQLite. Description while writing a test case for #33470 i found that for sqlite, even a seemingly db-transparent change like adding choices still generates sql (new table + insert + drop + rename) even though this shouldn't be needed. on e.g. postgr...
It was missed in #25253 (see 9159d173c3822312c653db7ff5b9a94b14af1dca). Adding choices to the non_database_attrs should fix it: django/db/backends/base/schema.py diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 4cd4567cbc..822da656d3 100644 a b class BaseDatabaseSchemaEditor: 113...
2022-04-01T18:29:04Z
<patch> 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 @@ -1376,22 +1376,9 @@ def _field_should_be_altered(self, old_field, new_field): # - changing only a field name # - changing an att...
diff --git a/tests/schema/tests.py b/tests/schema/tests.py --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -3961,6 +3961,20 @@ def test_alter_field_fk_attributes_noop(self): with connection.schema_editor() as editor, self.assertNumQueries(0): editor.alter_field(Book, new_field, old_fiel...
4.1
["test_alter_field_choices_noop (schema.tests.SchemaTests)"]
["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15563
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> Wrong behavior on queryset update when multiple inheritance Description Queryset update has a wrong behavior when queryset class inherits multiple classes. The update happens not on child class but on other p...
django/django
9ffd4eae2ce7a7100c98f681e2b6ab818df384a4
Wrong behavior on queryset update when multiple inheritance Description Queryset update has a wrong behavior when queryset class inherits multiple classes. The update happens not on child class but on other parents class instances. Here an easy example to show the problem: class Base(models.Model): base_id = models....
Thank you for your report. Confirmed this is another issue with concrete MTI. I've looked at the code and in order to address the issue both sql.UpdateQuery and sql.SQLUpdateCompiler need to be updated. The changes revolve around changing UpdateQuery.related_ids: list[int] to related_ids: dict[Model, list[int]] and mak...
2022-04-06T02:48:01Z
<patch> diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1836,7 +1836,23 @@ def pre_sql_setup(self): query.clear_ordering(force=True) query.extra = {} query.select = [] - q...
diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py --- a/tests/model_inheritance_regress/tests.py +++ b/tests/model_inheritance_regress/tests.py @@ -667,3 +667,15 @@ def test_create_new_instance_with_pk_equals_none_multi_inheritance(self): Politician.objects.ge...
4.1
["test_mti_update_grand_parent_through_child (model_inheritance_regress.tests.ModelInheritanceTest)", "test_mti_update_parent_through_child (model_inheritance_regress.tests.ModelInheritanceTest)"]
["test_abstract_base_class_m2m_relation_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_abstract_base_class_m2m_relation_inheritance_manager_reused (model_inheritance_regress.tests.ModelInheritanceTest)", "verbose_name_plural correctly inherited from ABC if inheritance chain", "Regression tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django__django-15569
You will be provided with a partial code base and an issue statement explaining a problem to resolve. <issue> RegisterLookupMixin._unregister_lookup() should clear the lookup cache. Description (last modified by Himanshu Balasamanta) In current source code, in the _unregister_lookup method, ​https://github.com/...
django/django
884b4c27f506b3c29d58509fc83a35c30ea10d94
RegisterLookupMixin._unregister_lookup() should clear the lookup cache. Description (last modified by Himanshu Balasamanta) In current source code, in the _unregister_lookup method, ​https://github.com/django/django/blame/main/django/db/models/query_utils.py#L212, the cache is not cleared, which should be done,...
Hi Himanshu. This may be right, yes — I need to have a sit-down and play with it. Main question: Are you able to put together an example case where the wrong result arrises? I was looking at ​PR #6906 which added the cache clearing. Also noting the For use in tests only... in the _unregister_lookup docstring. So this w...
2022-04-08T06:55:17Z
<patch> diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -217,6 +217,7 @@ def _unregister_lookup(cls, lookup, lookup_name=None): if lookup_name is None: lookup_name = lookup.lookup_name ...
diff --git a/tests/custom_lookups/tests.py b/tests/custom_lookups/tests.py --- a/tests/custom_lookups/tests.py +++ b/tests/custom_lookups/tests.py @@ -323,6 +323,8 @@ def test_lookups_caching(self): with register_lookup(models.ForeignObject, Exactly): # getting the lookups again should re-cache ...
4.1
["test_get_transforms (model_fields.test_jsonfield.TestMethods)", "test_lookups_caching (custom_lookups.tests.LookupTests)"]
["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_subquery_usage (custom_lookups.tests.SubqueryTransformTests)", "test_call_order (custom_lookups.tests.LookupTransformCallOrderTests)", "test_overridden_get_lookup (cu...
647480166bfe7532e8c471fef0146e3a17e6c0c9