repo
stringclasses
12 values
instance_id
stringlengths
18
32
base_commit
stringlengths
40
40
patch
stringlengths
344
252k
test_patch
stringlengths
398
22.9k
problem_statement
stringlengths
119
25.4k
hints_text
stringlengths
1
55.7k
created_at
stringlengths
20
20
version
float64
0.12
2.02k
FAIL_TO_PASS
stringlengths
12
120k
PASS_TO_PASS
stringlengths
2
114k
environment_setup_commit
stringclasses
89 values
django/django
django__django-13233
41065cfed56d5408dd8f267b9e70089471a7f1be
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 @@ -299,6 +299,10 @@ def pre_save(self, model_instance, add): file.save(file.name, file.file, save=False) return file + def contribute...
diff --git a/tests/model_fields/test_filefield.py b/tests/model_fields/test_filefield.py --- a/tests/model_fields/test_filefield.py +++ b/tests/model_fields/test_filefield.py @@ -8,8 +8,9 @@ from django.core.files import File, temp from django.core.files.base import ContentFile from django.core.files.uploadedfile im...
The `model` attribute of image fields doesn't point to concrete model. Description In Django 3.1 and before, one could use the model attribute of image fields to find the concrete model the image field belongs to. This isn't possible in 3.2 anymore, and I bisected the change to the fix of #31701. I found this while i...
null
2020-07-24T06:59:52Z
3.2
["test_abstract_filefield_model (model_fields.test_filefield.FileFieldTests)"]
["test_changed (model_fields.test_filefield.FileFieldTests)", "test_clearable (model_fields.test_filefield.FileFieldTests)", "test_defer (model_fields.test_filefield.FileFieldTests)", "test_delete_when_file_unset (model_fields.test_filefield.FileFieldTests)", "test_media_root_pathlib (model_fields.test_filefield.FileFi...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13237
3a6fa1d962ad9bd5678290bc22dd35bff13eb1f5
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 @@ -1037,10 +1037,16 @@ def _field_indexes_sql(self, model, field): return output def _field_should_be_altered(self, old_field, new_field): -...
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 @@ -1354,6 +1354,59 @@ def test_alter_field(self): self.assertEqual(definition[1], []) self.assertEqual(sorted(definition[2]), ["fi...
AlterField with db_column addition should be a noop. Description (last modified by Iuri de Silvio) When I change pink = models.Integer(default=0) to pink = models.Integer(default=0, db_column="pink") the migration drop/create the same constraints when it is an FK or even reconstruct the table (SQLite), but noth...
null
2020-07-25T13:52:40Z
3.2
["test_alter_field_add_db_column_noop (migrations.test_operations.OperationTests)"]
["A field may be migrated from AutoField to BigAutoField.", "A field may be migrated from SmallAutoField to AutoField.", "A field may be migrated from SmallAutoField to BigAutoField.", "RenameModel renames a many-to-many column after a RenameField.", "test_add_binaryfield (migrations.test_operations.OperationTests)", "...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13250
bac5777bff8e8d8189193438b5af52f158a3f2a4
diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py --- a/django/db/backends/base/features.py +++ b/django/db/backends/base/features.py @@ -295,6 +295,9 @@ class BaseDatabaseFeatures: has_native_json_field = False # Does the backend use PostgreSQL-style JSON operators like '...
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 @@ -1,6 +1,6 @@ import operator import uuid -from unittest import mock, skipIf, skipUnless +from unittest import mock, skipIf from django im...
JSONField's __contains and __contained_by lookups don't work with nested values on SQLite. Description SQLite doesn't provide a native way for testing containment of JSONField. The current implementation works only for basic examples without supporting nested structures and doesn't follow "the general principle that ...
OK, grrrr... — Just a case of doc-ing the limitations. 🤨 (Thanks) Draft. I've attached a draft solution but it's really hot and it doesn't handle list with dicts (...deep rabbit hole). IMO we should drop support for these lookups on SQLite, at least for now. Testing containment of JSONField is really complicated, I ho...
2020-07-28T10:26:49Z
3.2
["test_contained_by_unsupported (model_fields.test_jsonfield.TestQuerying)", "test_contains_unsupported (model_fields.test_jsonfield.TestQuerying)"]
["test_custom_encoder (model_fields.test_jsonfield.TestValidation)", "test_custom_encoder_decoder (model_fields.test_jsonfield.JSONFieldTests)", "test_db_check_constraints (model_fields.test_jsonfield.JSONFieldTests)", "test_deconstruct (model_fields.test_jsonfield.TestMethods)", "test_deconstruct_custom_encoder_decode...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13251
b6dfdaff33f19757b1cb9b3bf1d17f28b94859d4
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 @@ -204,7 +204,7 @@ def __init__(self, model=None, query=None, using=None, hints=None): def query(self): if self._deferred_filter: negate, args, kwargs = self._de...
diff --git a/tests/queries/models.py b/tests/queries/models.py --- a/tests/queries/models.py +++ b/tests/queries/models.py @@ -42,6 +42,7 @@ class Note(models.Model): note = models.CharField(max_length=100) misc = models.CharField(max_length=10) tag = models.ForeignKey(Tag, models.SET_NULL, blank=True, n...
Filtering on a field named `negate` raises a TypeError Description Filtering on a model with a field named negate raises a TypeError. For example: class Foo(models.Model): negate = models.BooleanField() Foo.objects.filter(negate=True) raises TypeError: _filter_or_exclude() got multiple values for argument 'negate' n...
We should either document this limitation or change _filter_or_exclude and friends signature from (negate, *args, **kwargs) to (negate, args, kwargs). I think the second approach is favourable as there's not much benefits in using arguments unpacking in these private methods as long as the public methods filter and exc...
2020-07-28T11:59:53Z
3.2
["test_negate_field (queries.tests.Queries1Tests)"]
["#13227 -- If a queryset is already evaluated, it can still be used as a query arg", "Delete queries can safely contain sliced subqueries", "Subselects honor any manual ordering", "hint: inverting your ordering might do what you need", "test_21001 (queries.tests.EmptyStringsAsNullTest)", "test_AB_ACB (queries.tests.Un...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13281
63300f7e686c2c452763cb512df9abf7734fd588
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 @@ -546,7 +546,10 @@ def __reduce__(self): def __getstate__(self): """Hook to allow choosing the attributes to pickle.""" - return self.__dict__ + state = self.__d...
diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py --- a/tests/model_regress/tests.py +++ b/tests/model_regress/tests.py @@ -1,3 +1,4 @@ +import copy import datetime from operator import attrgetter @@ -256,3 +257,17 @@ def test_model_with_evaluate_method(self): dept = Department.objec...
FK field caching behavior change between 1.11.x and 2.x Description Whilst upgrading a codebase from 1.11.x to 2.0/2.2 I noticed a weird change in behavior of FK fields when copying model instances. At the bottom of the post there is a testcase that succeeds on 1.11.x and fails on 2.x I think the commit that changed ...
null
2020-08-07T08:42:11Z
3.2
["test_fields_cache_reset_on_copy (model_regress.tests.ModelFieldsCacheTest)"]
["test_chained_fks (model_regress.tests.ModelTests)", "test_date_filter_null (model_regress.tests.ModelTests)", "test_date_lookup (model_regress.tests.ModelTests)", "test_empty_choice (model_regress.tests.ModelTests)", "test_get_next_prev_by_field (model_regress.tests.ModelTests)", "test_get_next_prev_by_field_unsaved ...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13297
8954f255bbf5f4ee997fd6de62cb50fc9b5dd697
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 -from djan...
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...
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
3.2
["test_template_params_filtering (generic_views.test_base.DeprecationTests)"]
["A generic template view passes kwargs as context.", "A template view can be customized to return extra context.", "Default is a temporary redirect", "GET arguments can be URL-encoded when included in the redirected URL", "GET arguments can be included in the redirected URL", "Named pattern parameter should reverse to...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13300
7f4c9222dfe2f28ff8a7ffc56c28ccbadf19cf6f
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 @@ -1145,11 +1145,9 @@ class Exists(Subquery): output_field = fields.BooleanField() def __init__(self, queryset, negated=False, **kwargs): - # As ...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -22,7 +22,7 @@ from django.db.models.sql import constants from django.db.models.sql.datastructures import Join from django.test import SimpleTestCase, TestCase, skipUnlessDBFeatur...
Use `EXISTS(SELECT 1 ...)` for subqueries Description If you write a QuerySet call like so in Django... MyModel.objects.all().exists() the query run will be like so. SELECT 1 AS "a" FROM "myapp_mymodel" LIMIT 1; If you use the Exists() function to filter with a subquery like so... MyModel.objects.filter(Exists(MyOthe...
I could swear there was another ticket about that but I cannot find it. The logic to clear the column is a bit more complex than what you've described here but it's all detailed in Query.has_results ​(link) and SQLCompiler.has_results ​(link) so it could be added to Exists.as_sql. Ideally the logic would be encapsulate...
2020-08-13T03:21:51Z
3.2
["test_optimizations (expressions.tests.ExistsTests)"]
["test_F_reuse (expressions.tests.ExpressionsTests)", "test_aggregate_subquery_annotation (expressions.tests.BasicExpressionsTests)", "test_aggregates (expressions.tests.ReprTests)", "test_and (expressions.tests.CombinableTests)", "test_annotate_values_aggregate (expressions.tests.BasicExpressionsTests)", "test_annotat...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13321
35b03788b0607c1f8d2b64e4fa9e1669b0907ea4
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 @@ -121,6 +121,15 @@ def decode(self, session_data): return signing.loads(session_data, salt=self.key_salt, serializ...
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 @@ -333,11 +333,16 @@ def test_default_hashing_algorith_legacy_decode(self): self.assertEqual(self.session._legacy_decode(encoded), data) def test_decode...
Decoding an invalid session data crashes. Description (last modified by Matt Hegarty) Hi I recently upgraded my staging server to 3.1. I think that there was an old session which was still active. On browsing to any URL, I get the crash below. It looks similar to ​this issue. I cannot login at all with Chrome -...
I tried to run clearsessions, but that didn't help. The only workaround was to delete all rows in the django_session table. Thanks for this report, however I cannot reproduce this issue. Can you provide a sample project? Support for user sessions created by older versions of Django remains until Django 4.0. See similar...
2020-08-18T10:43:52Z
3.2
["Falsey values (Such as an empty string) are rejected.", "Session repr should be the session key.", "Strings of length 8 and up are accepted and stored.", "Strings shorter than 8 characters are rejected.", "test_actual_expiry (sessions_tests.tests.CacheDBSessionTests)", "test_actual_expiry (sessions_tests.tests.CacheD...
[]
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13343
ece18207cbb64dd89014e279ac636a6c9829828e
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 ...
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...
null
2020-08-24T19:29:12Z
3.2
["test_deconstruction (file_storage.tests.FieldCallableFileStorageTests)"]
["Regression test for #9610.", "Saving to same file name twice overwrites the first file.", "The storage backend should preserve case of filenames.", "test_base_url (file_storage.tests.CustomStorageTests)", "test_base_url (file_storage.tests.DiscardingFalseContentStorageTests)", "test_base_url (file_storage.tests.FileS...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13347
b9be11d44265308863e4e8cfb458cd3605091452
diff --git a/django/views/debug.py b/django/views/debug.py --- a/django/views/debug.py +++ b/django/views/debug.py @@ -91,18 +91,19 @@ def cleanse_setting(self, key, value): value is a dictionary, recursively cleanse the keys in that dictionary. """ try: - if self.hidden_settings.s...
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 @@ -1274,6 +1274,19 @@ def test_cleanse_setting_recurses_in_dictionary(self): {'login': 'cooper', 'password': reporter_filter.cleans...
SafeExceptionReporterFilter does not recurse into dictionaries with non-string keys Description SafeExceptionReporterFilter has provisions for recursively cleaning settings by descending into lists / tuples / dictionaries - which is great! However, recursing on dictionaries only works if the keys of the dictionary ar...
null
2020-08-25T13:01:21Z
3.2
["test_cleanse_setting_recurses_in_dictionary_with_non_string_key (view_tests.tests.test_debug.ExceptionReporterFilterTests)"]
["A message can be provided in addition to a request", "A simple exception report can be generated", "An exception report can be generated even for a disallowed host.", "An exception report can be generated for just a request", "An exception report can be generated without request", "Large values should not create a la...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13355
e26a7a8ef41f0d69951affb21655cdc2cf94a209
diff --git a/django/forms/widgets.py b/django/forms/widgets.py --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -146,8 +146,14 @@ def merge(*lists): def __add__(self, other): combined = Media() - combined._css_lists = self._css_lists + other._css_lists - combined._js_lists = ...
diff --git a/tests/forms_tests/tests/test_media.py b/tests/forms_tests/tests/test_media.py --- a/tests/forms_tests/tests/test_media.py +++ b/tests/forms_tests/tests/test_media.py @@ -581,6 +581,7 @@ def test_merge_css_three_way(self): widget1 = Media(css={'screen': ['c.css'], 'all': ['d.css', 'e.css']}) ...
Optimize django.forms.widgets.Media.__add__. Description While working with another project that make extensive use of django.forms.widgets.Media I discovered that the fix for ticket #30153 has unintended consequences on the performance of Media.__add__. If the number of Media objects added grows beyond a certain poi...
I confirmed that 959d0c078a1c903cd1e4850932be77c4f0d2294d caused a performance issue. We should be able to optimize this by calling merge more often. I wonder how many distinct lists of assets you have? In the example above you're merging the same list 100'000 times. When calling merge earlier than at the end it will a...
2020-08-27T18:08:56Z
3.2
["test_add_css_deduplication (forms_tests.tests.test_media.FormsMediaTestCase)", "test_add_empty (forms_tests.tests.test_media.FormsMediaTestCase)", "test_add_js_deduplication (forms_tests.tests.test_media.FormsMediaTestCase)"]
["test_combine_media (forms_tests.tests.test_media.FormsMediaTestCase)", "test_construction (forms_tests.tests.test_media.FormsMediaTestCase)", "test_form_media (forms_tests.tests.test_media.FormsMediaTestCase)", "test_html_safe (forms_tests.tests.test_media.FormsMediaTestCase)", "test_media_deduplication (forms_tests....
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13363
76e0151ea0e0f56dca66cee846a78b89346d2c4c
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 truncate...
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...
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
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_day_func (db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests)", "test_extract_duration_unsupported_lookups (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_unsupp...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13371
3a9f192b131f7a9b0fe5783c684b23015fa67cc8
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 @@ -5,8 +5,6 @@ import copy import operator import warnings -from collections import namedtuple -from functools import lru_cache from itertools import chain import django @@ -23,7 +2...
diff --git a/tests/queries/tests.py b/tests/queries/tests.py --- a/tests/queries/tests.py +++ b/tests/queries/tests.py @@ -2408,6 +2408,11 @@ def test_named_values_list_expression(self): values = qs.first() self.assertEqual(values._fields, ('combinedexpression2', 'combinedexpression1')) + def tes...
django.db.models.query.Row is not pickleable. Description (last modified by Mariusz Felisiak) The new named parameter of QuerySet.values_list() was released In Django 2.0 (#15648). But resulted namedtuple-s can't be pickled: class ModelA(models.Model): value = models.CharField(max_length=12) In [12]: row = Mod...
In addition to the data contained in the instances, pickle also stores a string reference to the original class. This means that Row tuple class should be in query module globals so pickle can find the reference. But besides that, it should have different class names for each model and for each list of values. ​PR You ...
2020-08-31T08:55:35Z
3.2
["test_named_values_pickle (queries.tests.ValuesQuerysetTests)"]
["#13227 -- If a queryset is already evaluated, it can still be used as a query arg", "Delete queries can safely contain sliced subqueries", "Subselects honor any manual ordering", "hint: inverting your ordering might do what you need", "test_21001 (queries.tests.EmptyStringsAsNullTest)", "test_AB_ACB (queries.tests.Un...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13447
0456d3e42795481a186db05719300691fe2a1029
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 @@ -461,6 +461,7 @@ def _build_app_dict(self, request, label=None): info = (app_label, model._meta.model_name) model_dict = { + 'm...
diff --git a/tests/admin_views/test_adminsite.py b/tests/admin_views/test_adminsite.py --- a/tests/admin_views/test_adminsite.py +++ b/tests/admin_views/test_adminsite.py @@ -55,7 +55,9 @@ def test_available_apps(self): admin_views = apps[0] self.assertEqual(admin_views['app_label'], 'admin_views') ...
Added model class to app_list context Description (last modified by Raffaele Salmaso) I need to manipulate the app_list in my custom admin view, and the easiest way to get the result is to have access to the model class (currently the dictionary is a serialized model). In addition I would make the _build_app_di...
null
2020-09-22T08:49:25Z
4
["test_available_apps (admin_views.test_adminsite.SiteEachContextTest)"]
["AdminSite.get_action() returns an action even if it's disabled.", "test_add_action (admin_views.test_adminsite.SiteActionsTests)", "test_disable_action (admin_views.test_adminsite.SiteActionsTests)", "test_each_context (admin_views.test_adminsite.SiteEachContextTest)", "test_each_context_site_url_with_script_name (ad...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-13449
2a55431a5678af52f669ffe7dff3dd0bd21727f8
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): template = '...
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...
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
3.2
["test_lag_decimalfield (expressions_window.tests.WindowFunctionTests)"]
["A query with RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.", "An alternative way to specify a query for FirstValue.", "Window expressions can't be used in an INSERT statement.", "Window expressions can't be used in an UPDATE statement.", "test_avg_salary_department (expressions_window.tests.WindowFunctio...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13484
292b3be698ef58aff9c215d62a444f66ead578c3
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 @@ -11,6 +11,7 @@ from django.core import exceptions from django.utils.functional import cached_property +from django...
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 @@ -219,6 +219,40 @@ def test_pickle_subquery_queryset_not_evaluated(self): with self.assertNumQueries(0): self.assert_pickles(groups) + def t...
Queryset crashes when recreated from a pickled query with FilteredRelation used in aggregation. 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 contains ...
Thanks for this ticket, I was able to reproduce this issue. Tests. Just a note, the failing queryset does not have to be constructed by setting the query param of a newly created queryset - like this: qs2 = Publication.objects.all() qs2.query = pickle.loads(pickle.dumps(qs.query)) The same problem occurs even if the wh...
2020-10-03T18:50:41Z
3.2
["test_pickle_filteredrelation (queryset_pickle.tests.PickleabilityTestCase)", "test_pickle_filteredrelation_m2m (queryset_pickle.tests.PickleabilityTestCase)"]
["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_datetime_callable_default_all (queryset_pickle.tests.PickleabilityTestCase)",...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13512
b79088306513d5ed76d31ac40ab3c15f858946ea
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 +401,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"'), + ...
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
3.2
["test_json_display_for_field (admin_utils.tests.UtilsTests)", "test_label_for_field (admin_utils.tests.UtilsTests)", "test_prepare_value (forms_tests.field_tests.test_jsonfield.JSONFieldTest)"]
["The widget can be overridden with an attribute.", "test_converted_value (forms_tests.field_tests.test_jsonfield.JSONFieldTest)", "test_custom_encoder_decoder (forms_tests.field_tests.test_jsonfield.JSONFieldTest)", "test_custom_widget_kwarg (forms_tests.field_tests.test_jsonfield.JSONFieldTest)", "test_cyclic (admin_...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13513
6599608c4d0befdcb820ddccce55f183f247ae4f
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, post_co...
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...
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
3.2
["test_innermost_exception_without_traceback (view_tests.tests.test_debug.ExceptionReporterTests)"]
["A message can be provided in addition to a request", "A simple exception report can be generated", "An exception report can be generated even for a disallowed host.", "An exception report can be generated for just a request", "An exception report can be generated without request", "Large values should not create a la...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13516
b7da588e883e12b8ac3bb8a486e654e30fc1c6c8
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): + if...
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...
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...
null
2020-10-08T19:00:01Z
3.2
["test_outputwrapper_flush (user_commands.tests.CommandTests)"]
["An unknown command raises CommandError", "BaseCommand.create_parser() passes kwargs to CommandParser.", "Exception raised in a command should raise CommandError with", "test_call_command_no_checks (user_commands.tests.CommandTests)", "test_call_command_option_parsing (user_commands.tests.CommandTests)", "test_call_co...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13569
257f8495d6c93e30ab0f52af4c488d7344bcf112
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, [...
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
3.2
["Random() is not included in the GROUP BY when used for ordering."]
["Subquery annotations are excluded from the GROUP BY if they are", "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.AggregateTe...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13660
50c3ac6fa9b7c8a94a6d1dc87edf775e3bc4d575
diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py --- a/django/core/management/commands/shell.py +++ b/django/core/management/commands/shell.py @@ -84,13 +84,13 @@ def python(self, options): def handle(self, **options): # Execute the command and exit. ...
diff --git a/tests/shell/tests.py b/tests/shell/tests.py --- a/tests/shell/tests.py +++ b/tests/shell/tests.py @@ -9,6 +9,13 @@ class ShellCommandTestCase(SimpleTestCase): + script_globals = 'print("__name__" in globals())' + script_with_inline_function = ( + 'import django\n' + 'def f():\n' + ...
shell command crashes when passing (with -c) the python code with functions. Description The examples below use Python 3.7 and Django 2.2.16, but I checked that the code is the same on master and works the same in Python 3.8. Here's how ​python -c works: $ python -c <<EOF " import django def f(): print(django.__ve...
​PR includes tests and documents the new feature in the release notes (but not in the main docs since it seems more like a bug fix than a new feature to me).
2020-11-09T22:43:32Z
3.2
["test_command_option_inline_function_call (shell.tests.ShellCommandTestCase)", "test_stdin_read_inline_function_call (shell.tests.ShellCommandTestCase)"]
["test_command_option (shell.tests.ShellCommandTestCase)", "test_command_option_globals (shell.tests.ShellCommandTestCase)", "test_shell_with_bpython_not_installed (shell.tests.ShellCommandTestCase)", "test_shell_with_ipython_not_installed (shell.tests.ShellCommandTestCase)", "test_stdin_read (shell.tests.ShellCommandT...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13667
4cce1d13cfe9d8e56921c5fa8c61e3034dc8e20c
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 @@ -1116,10 +1116,11 @@ def copy(self): def external_aliases(self): return self.query.external_aliases - def as_sql(self, compiler, connection, te...
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 @@ -3,6 +3,7 @@ from django.db import DatabaseError, NotSupportedError, connection from django.db.models import Exists, F, IntegerField, OuterR...
Augment QuerySet.exists() optimizations to .union().exists(). Description (last modified by Simon Charette) The QuerySet.exists method performs optimization by ​clearing the select clause, ​dropping ordering, and limiting the number of results to 1 if possible. A similar optimization can be applied for combined...
PR ​https://github.com/django/django/pull/13667
2020-11-11T22:27:30Z
3.2
["test_exists_union (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
django__django-13671
8f384505eee8ce95667d77cfc2a07d4abe63557c
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -52,6 +52,8 @@ def get_key_func(key_func): class BaseCache: + _missing_key = object() + def __init__(self, params): timeout = pa...
diff --git a/tests/cache/tests.py b/tests/cache/tests.py --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -278,6 +278,14 @@ class BaseCacheTests: # A common set of tests to apply to all cache backends factory = RequestFactory() + # RemovedInDjango41Warning: python-memcached doesn't support .get()...
Allow cache.get_or_set() to cache a None result Description (last modified by Phill Tornroth) get_or_set docstring says "If the key does not exist, add the key and set it to the default value." -- but that's not quite what it does. It will perform a set if the key doesn't exist, or if the cached value is None. ...
I agree with your analysis. I read through previous related issues (#26792, #28601) and didn't see a good reason for the current behavior. I would question if if default is not None: should be there in your proposal (i.e. why shouldn't None by cached?). Replying to Tim Graham: I agree with your analysis. I read through...
2020-11-12T12:42:55Z
3.2
["test_decr (cache.tests.DBCacheTests)", "test_decr (cache.tests.DBCacheWithTimeZoneTests)", "test_decr (cache.tests.FileBasedCachePathLibTests)", "test_decr (cache.tests.FileBasedCacheTests)", "test_decr_version (cache.tests.DBCacheTests)", "test_decr_version (cache.tests.DBCacheWithTimeZoneTests)", "test_decr_version...
["#20613/#18541 -- Ensures pickling is done outside of the lock.", "Add doesn't do anything in dummy cache backend", "All data types are ignored equally by the dummy cache", "Cache deletion is transparently ignored on the dummy cache backend", "Caches that have the TIMEOUT parameter undefined in the default", "Dummy ca...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13689
ead37dfb580136cc27dbd487a1f1ad90c9235d15
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 @@ -915,9 +915,13 @@ def get_source_expressions(self): return [self.expression] def get_group_by_cols(self, alias=None): - expression = self.e...
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -195,6 +195,18 @@ def test_q_expression_annotation_with_aggregation(self): self.assertEqual(book.isnull_pubdate, False) self.assertEqual(book.rating_count, 1) + ...
Aggregating when grouping on an ExpressionWrapper omits the expression from the group by Description I ran into this with Postgres on Django 3.1.3, I'm not sure what other versions it exists on. print( Fred.objects.annotate( bob_id__is_null=ExpressionWrapper( Q(bob_id=None), output_field=BooleanField() ) ...
For anyone else who ends up here you can Subquery your way out of this, although I've no idea what the performance implications of that are. I did some further digging and this only occurs on 3.1, it works fine on 2.0, 2.1, 2.2 and 3.0 I think this is related to https://code.djangoproject.com/ticket/32007 To test this,...
2020-11-17T22:35:05Z
3.2
["test_grouping_by_q_expression_annotation (annotations.tests.NonAggregateAnnotationTestCase)"]
["test_aggregate_alias (annotations.tests.AliasTests)", "test_aggregate_over_annotation (annotations.tests.NonAggregateAnnotationTestCase)", "test_alias_after_annotation (annotations.tests.AliasTests)", "test_alias_annotate_with_aggregation (annotations.tests.AliasTests)", "test_alias_annotation_expression (annotations...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13722
600ff26a85752071da36e3a94c66dd8a77ee314a
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 @@ -1946,6 +1946,20 @@ def history_view(self, request, object_id, extra_context=None): "admin/object_history.html" ], context) + def get_f...
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 @@ -951,6 +951,12 @@ class CityAdmin(admin.ModelAdmin): inlines = [RestaurantInlineAdmin] view_on_site = True + def get_formset_kwargs(self, request, obj, inline, prefix)...
Add a hook to customize the admin's formsets parameters Description New feature that adds a method on InlineModelAdmin for providing initial data for the inline formset. By default there is no implementation, although one could be implemented to use GET parameters like get_changeform_initial_data, but it wouldn't be ...
Currently the PR has merge conflicts I think we should add a more general customization hook that allows customizing the parameters passed to the ​formset initialization (which includes initial data). That could also allow the use case of #27240 which requires adding form_kwargs': {'request': request} to formset_params...
2020-11-26T20:54:43Z
4
["test_formset_kwargs_can_be_overridden (admin_views.tests.AdminViewBasicTest)"]
["#13749 - Admin should display link to front-end site 'View site'", "#21056 -- URL reversing shouldn't work for nonexistent apps.", "#8408 -- \"Show all\" should be displayed instead of the total count if", "'Save as new' should raise PermissionDenied for users without the 'add'", "'View on site should' work properly ...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-13741
d746f28949c009251a8741ba03d156964050717f
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) + kwargs.setdef...
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....
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
3.2
["test_readonly_field_has_changed (auth_tests.test_forms.ReadOnlyPasswordHashTest)"]
["An invalid login doesn't leak the inactive status of a user.", "The change form does not return the password value", "UserCreationForm password validation uses all of the form's data.", "test_both_passwords (auth_tests.test_forms.UserCreationFormTest)", "test_bug_14242 (auth_tests.test_forms.UserChangeFormTest)", "te...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13744
d8dfff2ab0edf7a1ca5255eccf45c447b2f9d57e
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -114,9 +114,8 @@ def __eq__(self, other): def close_caches(**kwargs): - # Some caches -- python-memcached in particular -- need to do a cleanup at the - # end ...
diff --git a/tests/cache/tests.py b/tests/cache/tests.py --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -11,6 +11,7 @@ import threading import time import unittest +import warnings from pathlib import Path from unittest import mock, skipIf @@ -34,13 +35,14 @@ from django.template.response import Templ...
Deprecate MemcachedCache. Description python-memcached is not maintained anymore (see ​python-memcached#95) and it makes difficulties in fixing some issues (e.g. #29867). Moreover we added a cache backend for pymemcache (#29887) so we have a good builtin alternative. I think it's time to deprecate the django.core.cac...
​Mailing list discussion I'm going to accept this. We can give it a few weeks to see if there's any objections/movement on python-memcached.
2020-12-03T08:23:13Z
3.2
["test_warning (cache.tests.MemcachedCacheDeprecationTests)"]
["#20613/#18541 -- Ensures pickling is done outside of the lock.", "Add doesn't do anything in dummy cache backend", "All data types are ignored equally by the dummy cache", "Cache deletion is transparently ignored on the dummy cache backend", "Caches that have the TIMEOUT parameter undefined in the default", "Dummy ca...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13794
fe886eee36be8022f34cfe59aa61ff1c21fe01d9
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): + return sel...
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...
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
3.2
["test_add08 (template_tests.filter_tests.test_add.AddTests)", "test_add09 (template_tests.filter_tests.test_add.AddTests)", "test_lazy_add (utils_tests.test_functional.FunctionalTests)"]
["Disallow this case because the decorated function wouldn't be cached.", "cached_property caches its value and behaves like a property.", "lazy also finds base class methods in the proxy object", "lazy finds the correct (overridden) method implementation", "test_add (template_tests.filter_tests.test_add.FunctionTests)...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13807
89fc144dedc737a79929231438f035b1d4a993c9
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').fetchal...
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):...
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
3.2
["test_check_constraints_sql_keywords (backends.tests.FkConstraintsTests)"]
["An executemany call with too many/not enough parameters will raise an exception (Refs #12612)", "Creating an existing table returns a DatabaseError", "Sequence names are correct when resetting generic relations (Ref #13941)", "Test creation of model with long name and long pk name doesn't error. Ref #8901", "last_exe...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13808
f054468cac325e8d8fa4d5934b939b93242a3730
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -152,10 +152,14 @@ class DatabaseWrapper(BaseDatabaseWrapper): def get_connection_params(self): settings_dict = self.setting...
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py --- a/tests/backends/postgresql/tests.py +++ b/tests/backends/postgresql/tests.py @@ -68,6 +68,36 @@ def test_database_name_too_long(self): with self.assertRaisesMessage(ImproperlyConfigured, msg): DatabaseWrapper...
Allow postgresql database connections to use postgres services Description (last modified by levihb) Postgres offers a way to make database connections through the use of services, which are basically equivalent to MySQL's options files. Server, database, username, etc information is stored by default in ~/.pg_...
Configuration without NAME already works for me, e.g.: 'default': { 'ENGINE': 'django.db.backends.postgresql', 'OPTIONS': { 'service': 'default_django_test' } }, so only setting PGSERVICE for ​the underlying command-line client and docs are missing. I don't mind creating a pull request for it, but would like to know wh...
2020-12-23T22:44:41Z
4
["test_service (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)"]
["test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_column (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_crash_password_does_not_leak (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "t...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-13820
98ad327864aed8df245fd19ea9d2743279e11643
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 namespaces. - ...
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...
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...
null
2020-12-28T22:07:57Z
3.2
["test_loading_package_without__file__ (migrations.test_loader.LoaderTests)"]
["Files prefixed with underscore, tilde, or dot aren't loaded.", "Migration directories without an __init__.py file are ignored.", "Tests loading a complex but erroneous set of squashed migrations", "Tests loading a complex set of squashed migrations", "Tests loading a squashed migration", "Tests loading a squashed mig...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13822
74fd233b1433da8c68de636172ee1c9c6d1c08c9
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -1614,7 +1614,11 @@ def contribute_to_class(self, cls, name, **kwargs): # related_name with one generated from the m2m field name. Django...
diff --git a/tests/invalid_models_tests/test_relative_fields.py b/tests/invalid_models_tests/test_relative_fields.py --- a/tests/invalid_models_tests/test_relative_fields.py +++ b/tests/invalid_models_tests/test_relative_fields.py @@ -3,7 +3,7 @@ from django.core.checks import Error, Warning as DjangoWarning from dja...
fields.E305 is raised on ManyToManyFields with related_name='+' in models in different apps but with the same name. Description (last modified by Aleksey Ruban) Django raises an error during creation a db migration if two models with the same name refer to the same model in m2m field. related_name='+' or 'foo+'...
Thanks for the report. It looks that app_label is missing in ​ManyToManyField.contribute_to_class(): self.remote_field.related_name = "_%s_%s_%s_+" % (cls._meta.app_label, cls.__name__.lower(), name)
2020-12-30T02:26:00Z
3.2
["test_no_clash_across_apps_without_accessor (invalid_models_tests.test_relative_fields.ReverseQueryNameClashTests)", "test_related_objects_include_hidden (model_meta.tests.RelatedObjectsTests)", "test_related_objects_include_hidden_local_only (model_meta.tests.RelatedObjectsTests)", "test_relations_related_objects (mo...
["Ref #22047.", "test_abstract_model_not_instantiated (model_meta.tests.AbstractModelTests)", "test_accessor_clash (invalid_models_tests.test_relative_fields.SelfReferentialFKClashTests)", "test_accessor_clash (invalid_models_tests.test_relative_fields.SelfReferentialM2MClashTests)", "test_ambiguous_relationship_model_...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13837
415f50298f97fb17f841a9df38d995ccf347dfcc
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.__main__ ...
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...
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...
null
2021-01-04T17:44:23Z
3.2
["test_run_as_non_django_module (utils_tests.test_autoreload.TestChildArguments)"]
[".pyc and .pyo files are included in the files list.", "iter_all_python_module_file() ignores weakref modules.", "test_calls_start_django (utils_tests.test_autoreload.RunWithReloaderTests)", "test_calls_sys_exit (utils_tests.test_autoreload.RunWithReloaderTests)", "test_check_errors (utils_tests.test_autoreload.TestIt...
65dfb06a1ab56c238cc80f5e1c31f61210c4577d
django/django
django__django-13924
7b3ec6bcc8309d5b2003d355fe6f78af89cfeb52
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 @@ -225,8 +225,9 @@ def apply_migration(self, state, migration, fake=False, fake_initial=False): # Alright, do it normally with...
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 @@ -1,11 +1,12 @@ from unittest import mock from django.apps.registry import apps as global_apps -from django.db import DatabaseError, connection +from d...
Migrations are marked applied even if deferred SQL fails to execute Description The changes introduced in c86a3d80a25acd1887319198ca21a84c451014ad to address #29721 fail to account for the possibility of the schema editor accumulation of deferred SQL which is run at SchemaEditor.__exit__ time.
null
2021-01-21T00:09:22Z
4
["Migrations are not recorded if deferred SQL application fails."]
["#24123 - All models of apps already applied which are", "#24123 - All models of apps being unapplied which are", "#24129 - Tests callback process", "#26647 - Unrelated applied migrations should be part of the final", "A new squash migration will be marked as applied even if all its", "Although the MigrationExecutor i...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-13933
42e8cf47c7ee2db238bf91197ea398126c546741
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, self.query...
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...
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
4
["test_modelchoicefield_value_placeholder (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_error_messages.FormsErrorMessagesTestCase)", "test_datefield (forms_tests.tests.test_error_messages.Form...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14017
466920f6d726eee90d5566e0a9948e92b33a122e
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())], connecto...
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], ...
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
4
["test_boolean_expression_combined (expressions.tests.BasicExpressionsTests)", "test_boolean_expression_combined_with_empty_Q (expressions.tests.BasicExpressionsTests)"]
["Complex expressions of different connection types are possible.", "Special characters (e.g. %, _ and \\) stored in database are", "This tests that SQL injection isn't possible using compilation of", "We can fill a value in all objects with an other value of the", "We can filter for objects, where a value is not equal...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14140
45814af6197cfd8f4dc72ee43b90ecde305a1d5a
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.db.mode...
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), +...
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
4
["test_boolean_expression_combined_with_empty_Q (expressions.tests.BasicExpressionsTests)", "test_deconstruct (queries.test_q.QTests)", "test_deconstruct_boolean_expression (queries.test_q.QTests)", "test_deconstruct_negated (queries.test_q.QTests)"]
["#21430 -- Verifies a warning is raised for querysets that are", "#24831 -- Cached properties on ManyToOneRel created in QuerySet.delete()", "A model not defined on module level is picklable.", "Complex expressions of different connection types are possible.", "Neither pickling nor unpickling a QuerySet.query with an ...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14151
474cc420bf6bc1067e2aaa4b40cf6a08d62096f7
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py --- a/django/middleware/csrf.py +++ b/django/middleware/csrf.py @@ -298,7 +298,10 @@ def process_view(self, request, callback, callback_args, callback_kwargs): if referer is None: return self._reject(request, REASON...
diff --git a/tests/csrf_tests/tests.py b/tests/csrf_tests/tests.py --- a/tests/csrf_tests/tests.py +++ b/tests/csrf_tests/tests.py @@ -353,6 +353,12 @@ def test_https_malformed_referer(self): req.META['HTTP_REFERER'] = 'https://' response = mw.process_view(req, post_form_view, (), {}) self.as...
CsrfViewMiddleware assumes referer header can be parsed Description Django's CsrfViewMiddleware assumes that the HTTP referer header is valid when checking it. Specifically, it doesn't handle the case of urlparse() raising a ValueError in this line (e.g. for urls like 'https://['): ​https://github.com/django/django/b...
Should the response in this scenario be something like this line? Or would a different response reason make more sense ​https://github.com/django/django/blob/45814af6197cfd8f4dc72ee43b90ecde305a1d5a/django/middleware/csrf.py#L248 Replying to AdamDonna: Should the response in this scenario be something like this line? O...
2021-03-19T09:44:03Z
4
["A POST HTTPS request with a bad referer is rejected."]
["A POST HTTP request with a good origin is accepted.", "A POST HTTPS request from an insecure referer should be rejected.", "A POST HTTPS request is accepted when USE_X_FORWARDED_PORT=True.", "A POST HTTPS request with a bad referer is rejected", "A POST HTTPS request with a good origin is accepted.", "A POST HTTPS re...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14282
3fec16e8acf0724b061a9e3cce25da898052bc9b
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 @@ -12,12 +12,19 @@ class PasswordResetTokenGenerator: """ key_salt = "django.contrib.auth.tokens.PasswordResetTokenGenerator" algorithm = None - secret = ...
diff --git a/tests/auth_tests/test_tokens.py b/tests/auth_tests/test_tokens.py --- a/tests/auth_tests/test_tokens.py +++ b/tests/auth_tests/test_tokens.py @@ -3,7 +3,9 @@ from django.conf import settings from django.contrib.auth.models import User from django.contrib.auth.tokens import PasswordResetTokenGenerator +f...
Cannot run makemigrations management command without a SECRET_KEY Description I believe #29324 intended to fix this issue. Steps to reproduce: $ cd $(mktemp -d) $ python -m venv venv $ source venv/bin/activate $ pip install 'Django>=3.2' $ python -m django startproject foo $ sed -ri '/SECRET_KEY/d' foo/foo/settings.p...
#29324 fix this issue for management commands that do not rely on the SECRET_KEY, as far as I'm aware check is not one of them. Have you tried with a custom management command? I am using the makemigrations command with the --check toggle to verify no new migrations are needed. I don’t think it needs a SECRET_KEY? Here...
2021-04-19T08:13:32Z
4
["test_secret_lazy_validation (auth_tests.test_tokens.TokenGeneratorTest)"]
["A valid token can be created with a secret other than SECRET_KEY by", "The token generated for a user created in the same request", "The token is valid after n seconds, but no greater.", "Updating the user email address invalidates the token.", "test_check_token_with_nonexistent_token_and_user (auth_tests.test_tokens...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14372
b81c7562fc33f50166d5120138d6398dc42b13c3
diff --git a/django/core/files/utils.py b/django/core/files/utils.py --- a/django/core/files/utils.py +++ b/django/core/files/utils.py @@ -1,16 +1,26 @@ import os +import pathlib from django.core.exceptions import SuspiciousFileOperation -def validate_file_name(name): - if name != os.path.basename(name): - ...
diff --git a/tests/file_storage/test_generate_filename.py b/tests/file_storage/test_generate_filename.py --- a/tests/file_storage/test_generate_filename.py +++ b/tests/file_storage/test_generate_filename.py @@ -1,6 +1,4 @@ import os -import sys -from unittest import skipIf from django.core.exceptions import Suspici...
Saving a FileField raises SuspiciousFileOperation in some scenarios. Description I came across this issue today when I was updating Django from 3.2.0 -> 3.2.1. It's directly caused by: ​https://docs.djangoproject.com/en/3.2/releases/3.2.1/#cve-2021-31542-potential-directory-traversal-via-uploaded-files Starting from ...
I am also experiencing this issue on 2.2.21. It's just as you described it. I'm going to apply your PR onto my 2.2.21 checkout and see if it resolves it for me also. Oh, good catch Brian! I forgot to mention the bug is also present in 3.1.9 and 2.2.21 as they contain the CVE-2021-31542 fix, too. Hi, I came across this ...
2021-05-10T08:46:50Z
4
["test_filefield_dangerous_filename (file_storage.test_generate_filename.GenerateFilenameStorageTests)", "test_filefield_dangerous_filename_dot_segments (file_storage.test_generate_filename.GenerateFilenameStorageTests)", "test_filefield_generate_filename_absolute_path (file_storage.test_generate_filename.GenerateFilen...
["A FileField with unique=True shouldn't allow two instances with the", "Calling delete on an unset FileField should not call the file deletion", "FieldField.open() returns self so it can be used as a context manager.", "FileField.model returns the concrete model for fields defined in an", "FileField.save_form_data() c...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14434
5e04e84d67da8163f365e9f5fcd169e2630e2873
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)) compi...
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...
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.
null
2021-05-23T12:27:14Z
4
["test_unique_constraint (schema.tests.SchemaTests)"]
["#23065 - Constraint names must be quoted if they contain capital letters.", "#23609 - Tests handling of default values when altering from NULL to NOT NULL.", "#23987 - effective_default() should be used as the field default when", "#24163 - Tests altering of ForeignKey to OneToOneField", "#24163 - Tests altering of O...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14441
c1d50b901b50672a46e7e5fe473c14da1616fc4e
diff --git a/django/core/files/images.py b/django/core/files/images.py --- a/django/core/files/images.py +++ b/django/core/files/images.py @@ -44,7 +44,10 @@ def get_image_dimensions(file_or_path, close=False): file_pos = file.tell() file.seek(0) else: - file = open(file_or_path, 'rb') + ...
diff --git a/tests/files/tests.py b/tests/files/tests.py --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -369,6 +369,10 @@ def test_valid_image(self): size = images.get_image_dimensions(fh) self.assertEqual(size, (None, None)) + def test_missing_file(self): + size ...
Prevent get_image_dimensions() crash on nonexistent images. Description When using the get_image_dimensions(), If a non existing file/path is passed, the function crashes
null
2021-05-24T15:21:01Z
4
["test_missing_file (files.tests.GetImageDimensionsTests)"]
["#8149 - File objects with", "ContentFile can accept both bytes and strings and the retrieved content", "ContentFile.size changes after a write().", "File objects should yield lines when iterated over.", "Multiple calls of get_image_dimensions() should return the same size.", "Open files passed into get_image_dimensio...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14453
ee408309d2007ecec4f43756360bd855d424cbf6
diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -626,9 +626,10 @@ def url_patterns(self): iter(patterns) except TypeError as e: msg = ( - "The included URLconf '{name}' does not appear to ...
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 @@ -271,8 +271,9 @@ def test_no_urls_exception(self): with self.assertRaisesMessage( ImproperlyConfigured, "The includ...
Added message when user mispells 'urlpatterns' in some 'urls' module Description I found this kind of error when I mispelled urlspattern instead of urlpatterns inside my blog/urls.py file. So the console was throwing an error, but this error do not helped me to found the problem. Check it: django.core.exceptions.Impr...
null
2021-05-26T19:20:15Z
4
["URLResolver should raise an exception when no urlpatterns exist.", "test_no_handler_exception (urlpatterns_reverse.tests.NoRootUrlConfTests)"]
["A Resolver404 is raised if resolving doesn't meet the basic", "A default application namespace can be used for lookup.", "A default application namespace is sensitive to the current app.", "A nested current_app should be split in individual namespaces (#24904).", "An application namespace without a default is sensiti...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14463
68ef274bc505cd44f305c03cbf84cf08826200a8
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 @@ -78,18 +78,16 @@ def table2model(table_name): ) yield "from %s import models" % self...
diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py --- a/tests/inspectdb/models.py +++ b/tests/inspectdb/models.py @@ -132,3 +132,11 @@ class Meta: ) ] required_db_features = {"supports_expression_indexes"} + + +class DbComment(models.Model): + rank = models.IntegerFiel...
Add the ability to define comments in table / columns Description (last modified by Jared Chung) Database-level comments are valuable for database administrators, data analysts, data scientists, and others who are looking to consume data that is managed by Django. Most Django-supported databases also support ta...
Initial implementation for postgresql_psycopg2 backend: ​https://github.com/niwibe/django/compare/issue_18468 Is only implemented the table comment sql. If accepted as a new feature, would be nice to make design decisions. Today I put the comment for table in class "Meta", another option is to use the first line of the...
2021-05-29T04:34:26Z
4.2
["#22030 - Adding a field with a default should work.", "#22275 - A migration with circular FK dependency does not try", "#22300 - Adding an FK in the same \"spot\" as a deleted CharField should", "#22435 - Adding a ManyToManyField should not prompt for a default.", "#22951 -- Uninstantiated classes with deconstruct ar...
[]
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-14480
795da6306a048b18c0158496b0d49e8e4f197a32
diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py --- a/django/db/backends/base/features.py +++ b/django/db/backends/base/features.py @@ -325,6 +325,9 @@ class BaseDatabaseFeatures: # Does the backend support non-deterministic collations? supports_non_deterministic_collati...
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 @@ -1704,6 +1704,28 @@ def test_filter_aggregates_negated_and_connector(self): attrgetter("pk"), ) + def test_filter_aggregate...
Add logical XOR support to Q() and QuerySet(). Description XOR seems to be available in ​Postgresql, ​MySQL, ​SequelServer and ​Oracle but NOT ​sqlite. Two stackoverflow questions cover this sort of thing: ​https://stackoverflow.com/questions/50408142/django-models-xor-at-the-model-level and ​https://stackoverflow.co...
It's probably best to write to the DevelopersMailingList to see if there's consensus about this (although having a working patch may help evaluate the idea). I wonder if it's possible to emulate XOR on SQLite similar to what we do for some other database functions. XOR is not officially supported on Oracle (see ​doc) y...
2021-06-02T19:49:22Z
4.1
["test_and (expressions.tests.CombinableTests)", "test_combine_empty_copy (queries.test_q.QTests)", "test_combine_negated_boolean_expression (queries.test_q.QTests)", "test_combine_not_q_object (queries.test_q.QTests)", "test_combine_xor_both_empty (queries.test_q.QTests)", "test_combine_xor_empty (queries.test_q.QTest...
["A ValueError is raised when the incorrect object type is passed to a", "An F() object referring to related column works correctly in group by.", "Annotate *args ordering should be preserved in values_list results.", "Can create an instance of a model with only the PK field (#17056).\"", "Cloning a queryset does not g...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14513
de4f6201835043ba664e8dcbdceffc4b0955ce29
diff --git a/django/core/management/commands/showmigrations.py b/django/core/management/commands/showmigrations.py --- a/django/core/management/commands/showmigrations.py +++ b/django/core/management/commands/showmigrations.py @@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand from django.db import D...
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -928,6 +928,15 @@ def test_migrate_record_squashed(self): recorder = MigrationRecorder(connection) recorder.record_applied("migrations",...
Better Indication of Squash Migration State in showmigrations Description In the discussion of #25231 (​https://github.com/django/django/pull/5112) it became clear that there was a disconnect between the current output of showmigrations and the actual recorded applied state of squashed migrations. Currently if all of...
null
2021-06-10T15:17:18Z
4
["Running migrate for a squashed migration should record as run"]
["--fake-initial only works if all tables created in the initial", "--squashed-name also works if a start migration is omitted.", "--squashed-name specifies the new migration's name.", "Allow `makemigrations --dry-run` to output the migrations file to", "Assuming you have 3 apps, `A`, `B`, and `C`, such that:", "For an...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14599
019424e44efe495bc5981eb9848c0bb398a6f068
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py --- a/django/middleware/csrf.py +++ b/django/middleware/csrf.py @@ -437,15 +437,25 @@ def process_view(self, request, callback, callback_args, callback_kwargs): return self._accept(request) def process_response(self, request, response): ...
diff --git a/tests/csrf_tests/tests.py b/tests/csrf_tests/tests.py --- a/tests/csrf_tests/tests.py +++ b/tests/csrf_tests/tests.py @@ -14,8 +14,9 @@ from django.views.decorators.csrf import csrf_exempt, requires_csrf_token from .views import ( - ensure_csrf_cookie_view, non_token_view_using_request_processor, - ...
CsrfViewMiddleware.process_response()'s csrf_cookie_needs_reset and csrf_cookie_set logic isn't right Description I noticed that the csrf_cookie_needs_reset and csrf_cookie_set logic inside CsrfViewMiddleware.process_response() isn't right: ​https://github.com/django/django/blob/fa35c8bdbc6aca65d94d6280fa463d5bc7baa5...
null
2021-07-06T01:37:59Z
4
["A CSRF cookie that needs to be reset is reset only once when the view", "A CSRF cookie with the wrong format is replaced during a GET request."]
["A POST HTTP request with a good origin is accepted.", "A POST HTTPS request from an insecure referer should be rejected.", "A POST HTTPS request is accepted if it receives a good referer with", "A POST HTTPS request is accepted when USE_X_FORWARDED_PORT=True.", "A POST HTTPS request with a bad referer is rejected", "...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14634
37e8367c359cd115f109d82f99ff32be219f4928
diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py --- a/django/views/generic/edit.py +++ b/django/views/generic/edit.py @@ -1,5 +1,5 @@ from django.core.exceptions import ImproperlyConfigured -from django.forms import models as model_forms +from django.forms import Form, models as model_forms f...
diff --git a/tests/generic_views/forms.py b/tests/generic_views/forms.py --- a/tests/generic_views/forms.py +++ b/tests/generic_views/forms.py @@ -15,3 +15,12 @@ class Meta: class ContactForm(forms.Form): name = forms.CharField() message = forms.CharField(widget=forms.Textarea) + + +class ConfirmDeleteForm(f...
Allow delete to provide a success message through a mixin. Description Add a mixin to show a message on successful object deletion.
The patch for this contribution Your patch sets the message before the object is deleted. What if deleting the object fails? Otherwise, this addition makes sense. Here is a pull request that approaches the problem from a different angle: ​https://github.com/django/django/pull/2585 Instead of adding a new mixin, the Del...
2021-07-13T14:08:36Z
4
["test_delete_with_form_as_post_with_validation_error (generic_views.test_edit.DeleteViewTests)", "test_set_messages_success_on_delete (messages_tests.test_mixins.SuccessMessageMixinTests)"]
["A form can be marked invalid in the form_valid() method (#25548).", "Test instance independence of initial data dict (see #16138)", "Test prefix can be set (see #18872)", "test_create (generic_views.test_edit.CreateViewTests)", "test_create_invalid (generic_views.test_edit.CreateViewTests)", "test_create_restricted (...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14667
6a970a8b4600eb91be25f38caed0a52269d6303d
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 @@ -2086,7 +2086,12 @@ def add_deferred_loading(self, field_names): self.deferred_loading = existing.union(field_names), True else: # Remo...
diff --git a/tests/defer/tests.py b/tests/defer/tests.py --- a/tests/defer/tests.py +++ b/tests/defer/tests.py @@ -49,8 +49,16 @@ def test_defer_only_chaining(self): qs = Primary.objects.all() self.assert_delayed(qs.only("name", "value").defer("name")[0], 2) self.assert_delayed(qs.defer("name...
QuerySet.defer() doesn't clear deferred field when chaining with only(). Description Considering a simple Company model with four fields: id, name, trade_number and country. If we evaluate a queryset containing a .defer() following a .only(), the generated sql query selects unexpected fields. For example: Company.ob...
Replying to Manuel Baclet: Considering a simple Company model with four fields: id, name, trade_number and country. If we evaluate a queryset containing a .defer() following a .only(), the generated sql query selects unexpected fields. For example: Company.objects.only("name").defer("name") loads all the fields with th...
2021-07-19T21:08:03Z
4
["test_defer_only_chaining (defer.tests.DeferTests)"]
["Ensure select_related together with only on a proxy model behaves", "When an inherited model is fetched from the DB, its PK is also fetched.", "test_custom_refresh_on_deferred_loading (defer.tests.TestDefer2)", "test_defer (defer.tests.DeferTests)", "test_defer_baseclass_when_subclass_has_added_field (defer.tests.Big...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14722
c1e4111c74ee9d9f48cbee5a5b7c40289203c93d
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 @@ -178,8 +178,12 @@ def _detect_changes(self, convert_apps=None, graph=None): # Generate index removal operations before field is remov...
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 @@ -1570,9 +1570,26 @@ def test_foo_together_ordering(self): ) # Right number/type of migrations? self.assertNumbe...
Moving a unique constraint from unique_together to Field.unique generate an invalid migration. Description You can see a demo example to show the bug at [github](​https://github.com/ramwin/testunique/). I met a problem when I convert a unique_together to the unique=True attribute. first commit, everything is ok I cr...
this is a small project which can repeat the bug. Thank your for your report. I guess this is a bug in the auto-detector where the AlterUniqueTogether should appear before the AlterField that adds the Field.unique=True. I assume this is the case because generate_altered_unique_together is run after generate_altered_fie...
2021-07-31T17:43:56Z
4.1
["Fields are altered after deleting some index/unique_together.", "Removed fields will be removed after updating index/unique_together.", "index/unique_together also triggers on ordering changes."]
["#22030 - Adding a field with a default should work.", "#22275 - A migration with circular FK dependency does not try", "#22300 - Adding an FK in the same \"spot\" as a deleted CharField should", "#22435 - Adding a ManyToManyField should not prompt for a default.", "#22951 -- Uninstantiated classes with deconstruct ar...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14733
ae89daf46f83a7b39d599d289624c3377bfa4ab1
diff --git a/django/forms/formsets.py b/django/forms/formsets.py --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -2,7 +2,7 @@ from django.forms import Form from django.forms.fields import BooleanField, IntegerField from django.forms.utils import ErrorList -from django.forms.widgets import HiddenInpu...
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py --- a/tests/forms_tests/tests/test_formsets.py +++ b/tests/forms_tests/tests/test_formsets.py @@ -551,6 +551,38 @@ def test_formset_with_deletion_invalid_deleted_form(self): self.assertEqual(formset._errors, []) ...
Allow overriding of deletion widget in formsets Description In Django 3.0 ordering_widget and get_ordering_widget() were introduced (see #29956). The typical use case was to easily override the ORDER field in formsets that are updated in the frontend. For the exact same use case, I'd find it useful to see deletion_wi...
Thanks, sounds reasonable. ​PR
2021-08-03T09:07:47Z
4
["test_formset_with_deletion_custom_widget (forms_tests.tests.test_formsets.FormsFormsetTestCase)"]
["A FormSet can be prefilled with existing data by providing a list of", "A FormSet constructor takes the same arguments as Form. Create a", "A form that's displayed as blank may be submitted as blank.", "A formset has a hard limit on the number of forms instantiated.", "A formset's ManagementForm is validated once per...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14751
274771df9133542df048cc104c19e7756f9d3715
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -57,9 +57,20 @@ def add_arguments(self, parser): '--check', action='store_tru...
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -1667,6 +1667,47 @@ class Meta: self.assertIn("model_name='sillymodel',", out.getvalue()) self.assertIn("name='silly_char',", out.getval...
Make makemigrations scriptable / script-friendly Description Currently, the makemigrations management command doesn't lend itself well to scripting. For example, it writes its progress output to stdout rather than stderr. Also, there doesn't appear to be a structured / programmatic way to figure out what files it has...
The current makemigrations command would seem to allow for everything you have asked. # Define People and Poll models >> python -m manage makemigrations Migrations for 'newspaper': newspaper\migrations\0001_initial.py - Create model People Migrations for 'polls': polls\migrations\0001_initial.py - Create model Poll # A...
2021-08-07T14:53:57Z
4.1
["With scriptable=True, log output is diverted to stderr, and only the", "test_makemigrations_scriptable_merge (migrations.test_commands.MakeMigrationsTests)"]
["--fake-initial only works if all tables created in the initial", "--squashed-name also works if a start migration is omitted.", "--squashed-name specifies the new migration's name.", "Allow `makemigrations --dry-run` to output the migrations file to", "Assuming you have 3 apps, `A`, `B`, and `C`, such that:", "For an...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14762
cdad96e6330cd31185f7496aaf8eb316f2773d6d
diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -213,7 +213,7 @@ def gfk_key(obj): gfk_key, True, self.name, - True, + False,...
diff --git a/tests/contenttypes_tests/test_fields.py b/tests/contenttypes_tests/test_fields.py --- a/tests/contenttypes_tests/test_fields.py +++ b/tests/contenttypes_tests/test_fields.py @@ -2,14 +2,14 @@ from django.contrib.contenttypes.fields import GenericForeignKey from django.db import models -from django.test...
prefetch_related() for deleted GenericForeignKey is not consistent. Description prefetch_related called for GenericForeignKey sets content_type_id and object_id to None, if the foreign object doesn't exist. This behaviour is not documented. GenericForignKey is often used for audit records, so it can keep links to non...
Hi Martin. I do agree that's a little surprising. I'll accept as a Documentation issue on the content types app, but I'll cc Simon and Mariusz, in case they want to take it as a bug. Thanks. I didn't look at the issue in detail but I assume this is happening due to the prefetching logic performing a tags_2[0].content_o...
2021-08-11T15:01:48Z
4.1
["test_deleted_GFK (prefetch_related.tests.GenericRelationTests)", "test_get_object_cache_respects_deleted_objects (contenttypes_tests.test_fields.GenericForeignKeyTests)"]
["A 'content_object' can be traversed with prefetch_related() and", "A m2m can be followed through another m2m.", "A m2m relation can be followed after a relation like ForeignKey that", "A m2m relation can be followed after going through the select_related", "A model (Bio) with a OneToOneField primary key (author) that...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14792
d89f976bddb49fb168334960acc8979c3de991fa
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 offset ...
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...
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
4
["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
django__django-14855
475cffd1d64c690cdad16ede4d5e81985738ceb4
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: - url =...
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...
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
4
["test_readonly_foreignkey_links_custom_admin_site (admin_views.tests.ReadonlyTest)"]
["#13749 - Admin should display link to front-end site 'View site'", "#21056 -- URL reversing shouldn't work for nonexistent apps.", "#8408 -- \"Show all\" should be displayed instead of the total count if", "'Save as new' should raise PermissionDenied for users without the 'add'", "'View on site should' work properly ...
475cffd1d64c690cdad16ede4d5e81985738ceb4
django/django
django__django-14871
32b7ffc2bbfd1ae055bdbe287f8598de731adce1
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -388,6 +388,7 @@ def __init__(self, field, admin_site, attrs=None, choices=(), using=None): self.db = using self.choices = choices self...
diff --git a/tests/admin_widgets/test_autocomplete_widget.py b/tests/admin_widgets/test_autocomplete_widget.py --- a/tests/admin_widgets/test_autocomplete_widget.py +++ b/tests/admin_widgets/test_autocomplete_widget.py @@ -72,7 +72,8 @@ def test_build_attrs(self): 'data-app-label': 'admin_widgets', ...
Select2 doesn't load translations with subtags. Description For example, when using the setting LANGUAGE_CODE="pt-BR", the translation of select2 is not applied, the static file i18n is not found. This is due to the fact that some languages are converted to lowercase. ​https://github.com/django/django/blob/main/djan...
I fixed it ​https://github.com/django/django/pull/14813 LANGUAGE_CODE should be lowercased, so pt-br instead of pt-BR, see ​Definitions, ​LANGUAGE_CODE docs, and the list of ​LANGUAGES. Replying to Mariusz Felisiak: LANGUAGE_CODE should be lowercased, so pt-br instead of pt-BR, see ​Definitions, ​LANGUAGE_CODE docs, an...
2021-09-20T19:03:15Z
4.1
["test_build_attrs (admin_widgets.test_autocomplete_widget.AutocompleteMixinTests)"]
["Empty option is present if the field isn't required.", "Empty option isn't present if the field isn't required.", "test_build_attrs_no_custom_class (admin_widgets.test_autocomplete_widget.AutocompleteMixinTests)", "test_build_attrs_not_required_field (admin_widgets.test_autocomplete_widget.AutocompleteMixinTests)", "...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14880
402ae37873974afa5093e6d6149175a118979cd9
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -239,7 +239,9 @@ def _check_clashes(self): if not rel_is_hidden and clash_field.name == rel_name: errors.append( ...
diff --git a/tests/invalid_models_tests/test_relative_fields.py b/tests/invalid_models_tests/test_relative_fields.py --- a/tests/invalid_models_tests/test_relative_fields.py +++ b/tests/invalid_models_tests/test_relative_fields.py @@ -862,8 +862,8 @@ class Model(models.Model): self.assertEqual(Model.check(),...
Improve error messages for reverse accessor clashes. Description refer: ​https://github.com/django/django/pull/14880 RelatedField._check_clashes() provides feedback when it finds a clash, but fails to mentioned what the clashing name was. This cost me some significant time to track because of inadequate feedback and ...
null
2021-09-22T06:15:53Z
4.1
["Ref #22047.", "test_accessor_clash (invalid_models_tests.test_relative_fields.SelfReferentialFKClashTests)", "test_accessor_clash (invalid_models_tests.test_relative_fields.SelfReferentialM2MClashTests)", "test_clash_between_accessors (invalid_models_tests.test_relative_fields.AccessorClashTests)", "test_clash_betwee...
["#25723 - Referenced model registration lookup should be run against the", "#25723 - Through model registration lookup should be run against the", "If ``through_fields`` kwarg is given, it must specify both", "In contrast to standard Python MRO, resolution of inherited fields is", "ManyToManyField accepts the ``throug...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14894
9466fd78420a851460c92673dad50a5737c75b12
diff --git a/django/contrib/postgres/aggregates/statistics.py b/django/contrib/postgres/aggregates/statistics.py --- a/django/contrib/postgres/aggregates/statistics.py +++ b/django/contrib/postgres/aggregates/statistics.py @@ -36,7 +36,7 @@ class RegrAvgY(StatAggregate): class RegrCount(StatAggregate): function =...
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1367,7 +1367,7 @@ def test_empty_result_optimization(self): 'books_count': 0, } ) - # Expression without empty_aggregate_va...
Incorrect annotation value when doing a subquery with empty queryset Description ORM seems to generate annotation/subqueries incorrectly if empty queryset is used. Models: class Article(models.Model): author_name = models.CharField(max_length=100) content = models.TextField() is_public = models.BooleanField() cla...
The 0 assignment on empty result set comes from ​this line. I assume we could adjust the logic to rely on getattr(col, 'empty_aggregate_value', NotImplemented) and fallback to '0' if it's missing. Makes me wonder if we'd want to rename empty_aggregate_value to empty_result_set_value instead since it would not entirely ...
2021-09-24T20:08:24Z
4.1
["test_empty_queryset (db_functions.comparison.test_coalesce.CoalesceTests)", "test_empty_queryset_annotation (annotations.tests.NonAggregateAnnotationTestCase)", "test_gt_two_expressions (db_functions.comparison.test_coalesce.CoalesceTests)"]
[".dates() returns a distinct set of dates when applied to a", "Aggregation over sliced queryset works correctly.", "An annotation included in values() before an aggregate should be", "An annotation not included in values() before an aggregate should be", "Annotating None onto a model round-trips", "Annotations can ref...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14919
adb4100e58d9ea073ee8caa454bb7c885b6a83ed
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py --- a/django/db/backends/base/base.py +++ b/django/db/backends/base/base.py @@ -79,6 +79,8 @@ def __init__(self, settings_dict, alias=DEFAULT_DB_ALIAS): self.savepoint_state = 0 # List of savepoints created by 'atomic'. ...
diff --git a/django/test/testcases.py b/django/test/testcases.py --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1146,8 +1146,10 @@ def _enter_atomics(cls): """Open atomic blocks for multiple databases.""" atomics = {} for db_name in cls._databases_names(): - atom...
Do not ignore transaction durability errors within TestCase Description (last modified by Krzysztof Jagiełło) Currently there is a discrepancy in how durable atomic blocks are handled in TransactionTestCase vs TestCase. Using the former, nested durable atomic blocks will, as expected, result in a RuntimeError. ...
null
2021-09-30T19:26:20Z
4.1
["test_commit (transactions.tests.DurableTests)", "test_nested_both_durable (transactions.tests.DurableTests)", "test_nested_outer_durable (transactions.tests.DurableTests)", "test_sequence_of_durables (transactions.tests.DurableTests)"]
["#20028 -- Atomic must support wrapping callable instances.", "#23074 -- Savepoints must be released after rollback.", "#24921 -- ORM queries must be possible after set_autocommit(False).", "ORM queries are allowed after an error and a rollback in non-autocommit", "test_alternate_decorator_syntax_commit (transactions....
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14996
69b0736fad1d1f0197409ca025b7bcdf5666ae62
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 @@ -840,6 +840,20 @@ def generate_renamed_fields(self): old_field_dec[0:2] == field_dec[0:2] and ...
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 @@ -1001,14 +1001,17 @@ def test_rename_field_preserved_db_column(self): ] changes = self.get_changes(before, after, Migrat...
Renaming field and providing prior field name to db_column should be an SQL noop Description (last modified by Jacob Walls) Renaming a field and setting the prior implicit field name as the db_column to avoid db operations creates a migration emitting unnecessary SQL. Similar to #31826, which handled a very sim...
I think this is due to how the auto-detector ​generates field renames before field alterations. I assume the issue goes away if you swap the order of operations in your migration? ​As this test exemplifies the RenameField operation happens before the AlterField operation does so we'd need to adjust generate_renamed_fie...
2021-10-15T17:13:16Z
4.1
["RenameField is used if a field is renamed and db_column equal to the", "test_rename_related_field_preserved_db_column (migrations.test_autodetector.AutodetectorTests)"]
["#22030 - Adding a field with a default should work.", "#22275 - A migration with circular FK dependency does not try", "#22300 - Adding an FK in the same \"spot\" as a deleted CharField should", "#22435 - Adding a ManyToManyField should not prompt for a default.", "#22951 -- Uninstantiated classes with deconstruct ar...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14997
0d4e575c96d408e0efb4dfd0cbfc864219776950
diff --git a/django/db/backends/ddl_references.py b/django/db/backends/ddl_references.py --- a/django/db/backends/ddl_references.py +++ b/django/db/backends/ddl_references.py @@ -212,11 +212,7 @@ def __init__(self, table, expressions, compiler, quote_value): def rename_table_references(self, old_table, new_table):...
diff --git a/tests/backends/test_ddl_references.py b/tests/backends/test_ddl_references.py --- a/tests/backends/test_ddl_references.py +++ b/tests/backends/test_ddl_references.py @@ -5,6 +5,7 @@ from django.db.models import ExpressionList, F from django.db.models.functions import Upper from django.db.models.indexes ...
Remaking table with unique constraint crashes on SQLite. Description In Django 4.0a1, this model: class Tag(models.Model): name = models.SlugField(help_text="The tag key.") value = models.CharField(max_length=150, help_text="The tag value.") class Meta: ordering = ["name", "value"] constraints = [ models.Un...
Thanks for the report. Regression in 3aa545281e0c0f9fac93753e3769df9e0334dbaa. Thanks for the report! Looks like we don't check if an alias is set on the Col before we update it to new_table in Expressions.rename_table_references when running _remake_table.
2021-10-15T20:19:33Z
4.1
["test_alter_field_with_func_index (migrations.test_operations.OperationTests)", "test_alter_field_with_func_unique_constraint (migrations.test_operations.OperationTests)", "test_rename_table_references_without_alias (backends.test_ddl_references.ExpressionsTests)"]
["#23426 - RunSQL should accept parameters.", "#23426 - RunSQL should fail when a list of statements with an incorrect", "#24098 - Tests no-op RunPython operations.", "#24098 - Tests no-op RunSQL operations.", "#24282 - Model changes to a FK reverse side update the model", "A complex SeparateDatabaseAndState operation:...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-14999
a754b82dac511475b6276039471ccd17cc64aeb8
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 = to_st...
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...
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).
null
2021-10-16T09:31:21Z
4.1
["test_rename_model_with_db_table_noop (migrations.test_operations.OperationTests)"]
["#23426 - RunSQL should accept parameters.", "#23426 - RunSQL should fail when a list of statements with an incorrect", "#24098 - Tests no-op RunPython operations.", "#24098 - Tests no-op RunSQL operations.", "#24282 - Model changes to a FK reverse side update the model", "A complex SeparateDatabaseAndState operation:...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15018
1feb55d60736011ee94fbff9ba0c1c25acfd0b14
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 @@ -149,6 +149,12 @@ def get_actions(parser): opt.dest in options and (opt.required or opt in mutually_exclusive_required_optio...
diff --git a/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py b/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py new file mode 100644 --- /dev/null +++ b/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py @@ -0,...
call_command() fails when required mutually exclusive arguments use the same `dest`. Description I have a command which accepts two different ways to specify a time -- either as a timestamp or as a duration in the future: pause (--for duration | --until time) class Command(BaseCommand): def add_arguments(self, parse...
Thanks for the report. The following calls work as expected for me : management.call_command('pause', '--until=1') management.call_command('pause', '--until', '1') management.call_command('pause', '--for=1') management.call_command('pause', '--for', '1') however I confirmed an issue when passing arguments in keyword ar...
2021-10-22T14:41:17Z
4.1
["test_mutually_exclusive_group_required_with_same_dest_options (user_commands.tests.CommandTests)"]
["An unknown command raises CommandError", "BaseCommand.create_parser() passes kwargs to CommandParser.", "By default, call_command should not trigger the check framework, unless", "Exception raised in a command should raise CommandError with", "It should be possible to pass non-string arguments to call_command.", "Man...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15044
1f9874d4ca3e7376036646aedf6ac3060f22fd69
diff --git a/django/middleware/cache.py b/django/middleware/cache.py --- a/django/middleware/cache.py +++ b/django/middleware/cache.py @@ -67,7 +67,10 @@ def __init__(self, get_response): self.page_timeout = None self.key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX self.cache_alias = settin...
diff --git a/tests/cache/tests.py b/tests/cache/tests.py --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -994,9 +994,9 @@ def test_custom_key_func(self): self.assertEqual(caches['custom_key'].get('answer2'), 42) self.assertEqual(caches['custom_key2'].get('answer2'), 42) + @override_setti...
CacheMiddleware and FetchFromCacheMiddleware are not thread safe. Description CacheMiddleware persist self.cache = caches[cache_alias] on startup and it is not thread safe. ​https://github.com/django/django/blob/main/django/middleware/cache.py#L186 I found that after some production errors with pylibmc and uwsgi thre...
PR ​https://github.com/django/django/pull/15044 Possibly related to #33092. Thanks for the report!
2021-11-01T02:34:46Z
4.1
["The cache instance is different for each thread."]
["#20613/#18541 -- Ensures pickling is done outside of the lock.", "Add doesn't do anything in dummy cache backend", "All data types are ignored equally by the dummy cache", "Attempting to retrieve the same alias should yield the same instance.", "Cache deletion is transparently ignored on the dummy cache backend", "Ca...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15061
2c01ebb4be5d53cbf6450f356c10e436025d6d07
diff --git a/django/forms/widgets.py b/django/forms/widgets.py --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -849,9 +849,7 @@ def get_context(self, name, value, attrs): return context def id_for_label(self, id_): - if id_: - id_ += '_0' - return id_ + ret...
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 @@ -141,7 +141,7 @@ def test_form_as_table(self): self.assertHTMLEqu...
Remove "for = ..." from MultiWidget's <label>. Description The instance from Raw MultiWidget class generate id_for_label like f'{id_}0' It has not sense. For example ChoiceWidget has self.add_id_index and I can decide it myself, how I will see label_id - with or without index. I think, it is better to remove complete...
I agree that we should remove for from MultiWidget's <label> but not because "It has not sense" but to improve accessibility when using a screen reader, see also #32338. It should be enough to return an empty string: def id_for_label(self, id_): return '' ​PR
2021-11-04T17:15:53Z
4.1
["test_form_as_table (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_form_as_table (forms_tests.field_tests.test_splitdatetimefield.SplitDateTimeFieldTest)", "test_form_as_table_data (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)"]
["If insufficient data is provided, None is substituted.", "Test when the first widget's data has changed.", "Test when the last widget's data has changed. This ensures that it is", "test_bad_choice (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_clean (forms_tests.field_tests.test_multivalue...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15180
7e4a9a9f696574a18f5c98f34d5a88e254b2d394
diff --git a/django/urls/conf.py b/django/urls/conf.py --- a/django/urls/conf.py +++ b/django/urls/conf.py @@ -57,6 +57,10 @@ def include(arg, namespace=None): def _path(route, view, kwargs=None, name=None, Pattern=None): from django.views import View + if kwargs is not None and not isinstance(kwargs, dict):...
diff --git a/tests/urlpatterns/tests.py b/tests/urlpatterns/tests.py --- a/tests/urlpatterns/tests.py +++ b/tests/urlpatterns/tests.py @@ -4,7 +4,9 @@ from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from django.test.utils import override_settings -from django.urls impor...
path()/re_path() should raise a TypeError when kwargs is not a dict. Description Apparently, however many years into using Django, I'm still capable of making a "newbie" mistake and getting confused. So perhaps other actual new users encounter similar, especially given the lack of typing specifiers. I defined a URL l...
I agree that this behavior should be edited, but I think the ticket type should be Cleanup/optimization. Well, they actually continue to suggest to me that everything after the view argument should be keyword-only, or that kwargs should come later, but I suspect those to be a harder sell ;) Keyword-only arguments would...
2021-12-10T22:36:04Z
4.1
["test_invalid_kwargs (urlpatterns.tests.SimplifiedURLTests)"]
["test_allows_non_ascii_but_valid_identifiers (urlpatterns.tests.ParameterRestrictionTests)", "test_converter_resolve (urlpatterns.tests.SimplifiedURLTests)", "test_converter_reverse (urlpatterns.tests.SimplifiedURLTests)", "test_converter_reverse_with_second_layer_instance_namespace (urlpatterns.tests.SimplifiedURLTes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15204
b0d16d0129b7cc5978a8d55d2331a34cb369e6c7
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -42,11 +42,11 @@ iso8601_duration_re = _lazy_re_compile( r'^(?P<sign>[-+]?)' r'P' - r'(?:(?P<days>\d+(.\d+)?)D)?' + r'(?:(?P<days>\d+([\.,]\d+)?)D)?' r'(?:T' - r...
diff --git a/tests/forms_tests/field_tests/test_durationfield.py b/tests/forms_tests/field_tests/test_durationfield.py --- a/tests/forms_tests/field_tests/test_durationfield.py +++ b/tests/forms_tests/field_tests/test_durationfield.py @@ -30,6 +30,8 @@ def test_durationfield_clean(self): msg = 'Enter a valid d...
Durationfield.clean fails to handle broken data Description (last modified by Florian Apolloner) The actual input string was 'P3(3D' === Uncaught Python exception: === ValueError: could not convert string to float: '3(3' Traceback (most recent call last): File "basic_fuzzer.py", line 22, in TestOneInput ...
null
2021-12-15T17:08:34Z
4.1
["test_durationfield_clean (forms_tests.field_tests.test_durationfield.DurationFieldTest)", "test_iso_8601 (utils_tests.test_dateparse.DurationParseTests)", "test_minutes_seconds (utils_tests.test_dateparse.DurationParseTests)"]
["test_days (utils_tests.test_dateparse.DurationParseTests)", "test_durationfield_clean_not_required (forms_tests.field_tests.test_durationfield.DurationFieldTest)", "test_durationfield_integer_value (forms_tests.field_tests.test_durationfield.DurationFieldTest)", "test_durationfield_prepare_value (forms_tests.field_te...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15206
bf7afe9c4e21f5fe5090c47b2b6ffc5a03a85815
diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py --- a/django/views/decorators/cache.py +++ b/django/views/decorators/cache.py @@ -1,6 +1,5 @@ from functools import wraps -from django.http import HttpRequest from django.middleware.cache import CacheMiddleware from django.utils.cache...
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py --- a/tests/decorators/tests.py +++ b/tests/decorators/tests.py @@ -493,6 +493,15 @@ def a_view(request): self.assertIsNone(r.get('X-Frame-Options', None)) +class HttpRequestProxy: + def __init__(self, request): + self._request = ...
never_cache()/cache_control() decorators raise error on duck-typed requests. Description The cache decorators cache_control, never_cache and sensitive_post_parameters no longer work with Django REST framework because they strictly check for an HttpRequest instance.
Hi Terence — Thanks for the report. Can you post a traceback quickly, or better a reproduce? (But a traceback would be good.) 3fd82a62415e748002435e7bad06b5017507777c for #32468 looks likely. The check has been in sensitive_post_parameters ​for a long time. I don't see how this can be a regression, these decorators use...
2021-12-16T08:48:48Z
4.1
["test_cache_control_decorator_http_request_proxy (decorators.tests.CacheControlDecoratorTest)", "test_never_cache_decorator_http_request_proxy (decorators.tests.NeverCacheDecoratorTest)"]
["@method_decorator can accept a tuple of decorators.", "@method_decorator can be used to decorate a class and its methods.", "@method_decorator on a non-callable attribute raises an error.", "@method_decorator on a nonexistent method raises an error.", "@method_decorator preserves wrapper assignments.", "A decorator t...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15278
0ab58c120939093fea90822f376e1866fc714d1f
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 field on...
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...
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
4.1
["test_add_field_o2o_nullable (schema.tests.SchemaTests)"]
["#23065 - Constraint names must be quoted if they contain capital letters.", "#23609 - Tests handling of default values when altering from NULL to NOT NULL.", "#23738 - Can change a nullable field with default to non-nullable", "#23987 - effective_default() should be used as the field default when", "#24163 - Tests al...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15316
fdfa97fb166ef5065aa2b229f19cb4ce303084e5
diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -137,9 +137,10 @@ def default_reference_role(name, rawtext, text, lineno, inliner, options=None, c for name, urlbase in ROLES.items(): creat...
diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py --- a/tests/admin_docs/test_views.py +++ b/tests/admin_docs/test_views.py @@ -397,6 +397,13 @@ def test_simplify_regex(self): (r'^(?P<a>(x|y))/b/(?P<c>\w+)', '/<a>/b/<c>'), (r'^(?P<a>(x|y))/b/(?P<c>\w+)ab', '/<a>/b/<c...
simplify_regex() doesn't handle non-capturing groups Description (last modified by Mariusz Felisiak) While using Django REST Framework's Schema generator, I found out they're using simplify_regex(); however, current version has a few shortcomings, namely non-capturing groups are broken. simplify_regex() doesn't...
I left comments for improvement on the PR. Please uncheck "Patch needs improvement" after updating. This PR is no longer related to this issue. I have opened a ​pull request that allows simplify_regex() to handle non-capturing groups and additional tests for them in test_simplify_regex(). I've submitted a patch here ​h...
2022-01-14T04:36:43Z
4.1
["test_simplify_regex (admin_docs.test_views.AdminDocViewFunctionsTests)", "test_template_detail_path_traversal (admin_docs.test_views.AdminDocViewDefaultEngineOnly)"]
["A model with ``related_name`` of `+` shouldn't show backward", "Index view should correctly resolve view patterns when ROOT_URLCONF is", "Methods that begin with strings defined in", "Methods that take arguments should also displayed.", "Methods with arguments should have their arguments displayed.", "Methods with ke...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15380
71e7c8e73712419626f1c2b6ec036e8559a2d667
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 - self.old_fi...
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...
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...
null
2022-01-31T19:44:44Z
4.1
["test_rename_field_with_renamed_model (migrations.test_autodetector.AutodetectorTests)"]
["#22030 - Adding a field with a default should work.", "#22275 - A migration with circular FK dependency does not try", "#22300 - Adding an FK in the same \"spot\" as a deleted CharField should", "#22435 - Adding a ManyToManyField should not prompt for a default.", "#22951 -- Uninstantiated classes with deconstruct ar...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15382
770d3e6a4ce8e0a91a9e27156036c1985e74d4a3
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.exists(using...
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...
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
4.1
["test_negated_empty_exists (expressions.tests.ExistsTests)"]
["Complex expressions of different connection types are possible.", "Special characters (e.g. %, _ and \\) stored in database are", "The output field for a given Value doesn't get cleaned & validated,", "This tests that SQL injection isn't possible using compilation of", "We can fill a value in all objects with an othe...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15400
4c76ffc2d6c77c850b4bef8d9acc197d11c47937
diff --git a/django/utils/functional.py b/django/utils/functional.py --- a/django/utils/functional.py +++ b/django/utils/functional.py @@ -432,6 +432,12 @@ def __deepcopy__(self, memo): return result return copy.deepcopy(self._wrapped, memo) + __add__ = new_method_proxy(operator.add) + + @...
diff --git a/tests/utils_tests/test_lazyobject.py b/tests/utils_tests/test_lazyobject.py --- a/tests/utils_tests/test_lazyobject.py +++ b/tests/utils_tests/test_lazyobject.py @@ -317,6 +317,17 @@ def test_repr(self): self.assertIsInstance(obj._wrapped, int) self.assertEqual(repr(obj), "<SimpleLazyObje...
SimpleLazyObject doesn't implement __radd__ Description Technically, there's a whole bunch of magic methods it doesn't implement, compared to a complete proxy implementation, like that of wrapt.ObjectProxy, but __radd__ being missing is the one that's biting me at the moment. As far as I can tell, the implementation ...
Could you please give some sample code with your use case? In a boiled-down nutshell: def lazy_consumer(): # something more complex, obviously. return [1, 3, 5] consumer = SimpleLazyObject(lazy_consumer) # inside third party code ... def some_func(param): third_party_code = [...] # then, through parameter passing, my v...
2022-02-05T19:34:55Z
4.1
["test_add (utils_tests.test_lazyobject.SimpleLazyObjectTestCase)", "test_radd (utils_tests.test_lazyobject.SimpleLazyObjectTestCase)"]
["Test in a fairly synthetic setting.", "test_bool (utils_tests.test_lazyobject.LazyObjectTestCase)", "test_bool (utils_tests.test_lazyobject.SimpleLazyObjectTestCase)", "test_bytes (utils_tests.test_lazyobject.LazyObjectTestCase)", "test_bytes (utils_tests.test_lazyobject.SimpleLazyObjectTestCase)", "test_class (utils...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15421
be80aa55ec120b3b6645b3efb77316704d7ad948
diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py --- a/django/db/backends/sqlite3/creation.py +++ b/django/db/backends/sqlite3/creation.py @@ -1,8 +1,11 @@ +import multiprocessing import os import shutil +import sqlite3 import sys from pathlib import Path +from django.d...
diff --git a/django/test/runner.py b/django/test/runner.py --- a/django/test/runner.py +++ b/django/test/runner.py @@ -20,7 +20,12 @@ from django.core.management import call_command from django.db import connections from django.test import SimpleTestCase, TestCase -from django.test.utils import NullTimeKeeper, TimeK...
Allow parallel test runner to work with Windows/macOS `spawn` process start method. Description (last modified by Brandon Navra) Python 3.8 on MacOS has changed the default start method for the multiprocessing module from fork to spawn: ​https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-...
spawn() is also a default method on Windows, and we don't encounter any issues with it 🤔. I'm still trying to research the exact root cause. The Python issue which triggered this change has snippets of info: https://code.djangoproject.com/ticket/31169 but nothing conclusive. My theory is that the memory copying semant...
2022-02-13T10:23:00Z
4.1
["test_get_test_db_clone_settings_not_supported (backends.sqlite.test_creation.TestDbSignatureTests)"]
["# Regression test for #8027: custom ModelForms with fields/fieldsets", "'manage.py help test' works after r16352.", "A ContentType isn't created if the model isn't available.", "A GenericInlineModelAdmin errors if the ct_field points to a", "A GenericInlineModelAdmin errors if the ct_fk_field points to a", "A Generic...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15525
fbacaa58ffc5a62456ee68b90efa13957f761ce4
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"): ...
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
4.1
["Natural keys with foreing keys in dependencies works in a multiple"]
["Circular M2M relations with explicit through models should be serializable", "Data with nonexistent child key references raises error.", "Error is quickly reported when no fixtures is provided in the command", "Failing serializer import raises the proper error", "Fixtures can be rolled back (ticket #11101).", "Forwar...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15569
884b4c27f506b3c29d58509fc83a35c30ea10d94
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 de...
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 ...
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
4.1
["test_get_transforms (model_fields.test_jsonfield.TestMethods)", "test_lookups_caching (custom_lookups.tests.LookupTests)"]
["#23065 - Constraint names must be quoted if they contain capital letters.", "#23609 - Tests handling of default values when altering from NULL to NOT NULL.", "#23738 - Can change a nullable field with default to non-nullable", "#23987 - effective_default() should be used as the field default when", "#24163 - Tests al...
647480166bfe7532e8c471fef0146e3a17e6c0c9
django/django
django__django-15648
7e4656e4b2189390a433a149091442d53a777e2b
diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py --- a/django/contrib/syndication/views.py +++ b/django/contrib/syndication/views.py @@ -1,3 +1,5 @@ +from inspect import getattr_static, unwrap + from django.contrib.sites.shortcuts import get_current_site from django.core.exceptio...
diff --git a/tests/syndication_tests/feeds.py b/tests/syndication_tests/feeds.py --- a/tests/syndication_tests/feeds.py +++ b/tests/syndication_tests/feeds.py @@ -1,3 +1,5 @@ +from functools import wraps + from django.contrib.syndication import views from django.utils import feedgenerator from django.utils.timezone ...
views.Feed methods cannot be decorated Description If one applies a decorator on a method which is called by __get_dynamic_attr a TypeError like this occurs: Exception Type: TypeError at /blog/feed/ Exception Value: item_link() takes exactly 2 arguments (1 given) I think this is because __get_dynamic_attr tries to co...
Yes, that code is fragile. I reproduced it. I'm working now on fix. sample project, which show how patch works now I sended pull request. ​https://github.com/django/django/pull/2584 The problem is that methods without the 'item' argument (only with self) should be static now: @staticmethod def item_description(self): r...
2022-05-02T03:46:31Z
4.2
["test_rss2_feed_with_decorated_methods (syndication_tests.tests.SyndicationFeedTest)", "test_rss2_feed_with_wrong_decorated_methods (syndication_tests.tests.SyndicationFeedTest)"]
["An ImproperlyConfigured is raised if no link could be found for the", "Both the published and updated dates are", "Custom context data can be passed to templates for title", "Datetimes are correctly converted to the local time zone.", "Datetimes with timezones don't get trodden on.", "Test URLs are prefixed with http...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15698
1a78ef2b85467a18ea6d7eaa4b27f67d11c87b9e
diff --git a/django/template/base.py b/django/template/base.py --- a/django/template/base.py +++ b/django/template/base.py @@ -913,15 +913,18 @@ def _resolve_lookup(self, context): try: # method call (assuming no args required) current = current() ...
diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py --- a/tests/template_tests/tests.py +++ b/tests/template_tests/tests.py @@ -183,6 +183,14 @@ def test_node_origin(self): for node in template.nodelist: self.assertEqual(node.origin, template.origin) + def test_render_b...
Templates crash when calling methods for built-in types. Description (last modified by Daniel) Found during a 2.2 -> 3.2 upgrade: Given a template: {{ foo }} where foo is non-existant, it returns nothing, empty. (That's good) {{ foo.count }} also empty (Also good) {% include 'second_template.html' with bar=foo ...
Isn't a bug, that the template resolver tries to step into ''.<some_builtin_method> here? Maybe the for bit in self.lookups: descent could exit as soon as current drops to an empty string? Thanks for the report. foo may exist, the same error is raised for each method call for bultin types, e.g. def myview(request): ret...
2022-05-17T05:47:51Z
4.2
["Templates should not crash when rendering methods for built-in types"]
["# 16770 -- The template system doesn't wrap exceptions, but annotates", "#18169 -- NoReverseMatch should not be silence in block.super.", "#19827 -- url tag should keep original strack trace when reraising", "#24338 -- Allow extending django.template.backends.django.Template", "#25848 -- Set origin on Node so debuggi...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15732
ce69e34bd646558bb44ea92cecfd98b345a0b3e0
diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -528,7 +528,10 @@ def alter_unique_together(self, model, old_unique_together, new_unique_together) # Deleted uniques for fields in olds....
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -2809,6 +2809,69 @@ def test_alter_unique_together_remove(self): operation.describe(), "Alter unique_together for Pony (0 constraint(...
Cannot drop unique_together constraint on a single field with its own unique=True constraint Description I have an erroneous unique_together constraint on a model's primary key (unique_together = (('id',),)) that cannot be dropped by a migration. Apparently the migration tries to find all unique constraints on the co...
Can you share a traceback that shows how and where the migration fails, please. Here it is: Traceback (most recent call last): File "./bin/django", line 56, in <module> sys.exit(djangorecipe.manage.main('project.settings.local.foobar')) File "/foo/bar/eggs/djangorecipe-1.10-py2.7.egg/djangorecipe/manage.py", line 9, in...
2022-05-24T12:58:31Z
4.2
["test_remove_unique_together_on_unique_field (migrations.test_operations.OperationTests)"]
["#23426 - RunSQL should accept parameters.", "#23426 - RunSQL should fail when a list of statements with an incorrect", "#24098 - Tests no-op RunPython operations.", "#24098 - Tests no-op RunSQL operations.", "#24282 - Model changes to a FK reverse side update the model", "A complex SeparateDatabaseAndState operation:...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15737
f1e0fc645bb0b2c15d1510c9a8501743297dec9d
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 @@ -1100,9 +1100,9 @@ def _prepare_related_fields_for_save(self, operation_name, fields=None): "related object '%s'." % (operation_name, field.name) ...
diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -654,6 +654,16 @@ def test_fk_assignment_and_related_object_cache(self): self.assertIsNot(c.parent, p) self.assertEqual(c.parent, p) + def test_save_parent_aft...
Avoid unnecessary clear of cached reference Description (last modified by Barry Johnson) Consider this case of ORM models "Parent" and "Child", where Child has a foreign key reference to Parent (and the database can return generated IDs following insert operations): parent = Parent(name='parent_object') child =...
Hi Barry. Thanks for the report. For me, this is just how things are expected to work, so I'm going to say wontfix. I'm happy if you want to take it to the DevelopersMailingList for a wider discussion, but (in general) I'm suspicious of a "simple change" adjusting a long-standing behaviour like this… (Perhaps there's a...
2022-05-27T12:16:42Z
4.2
["test_save_parent_after_assign (many_to_one.tests.ManyToOneTests)"]
["Model.save() invalidates stale ForeignKey relations after a primary key", "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.ManyToOn...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15738
6f73eb9d90cfec684529aab48d517e3d6449ba8c
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 @@ -1022,8 +1022,9 @@ def generate_added_fields(self): def _generate_added_field(self, app_label, model_name, field_name): field ...
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 @@ -868,6 +868,18 @@ class AutodetectorTests(TestCase): "unique_together": {("title", "newfield2")}, }, ) + boo...
Models migration with change field foreign to many and deleting unique together. Description (last modified by Simon Charette) I have models like class Authors(models.Model): project_data_set = models.ForeignKey( ProjectDataSet, on_delete=models.PROTECT ) state = models.IntegerField() start_date = model...
Download this file and then do makemigrations and migrate to see this error. Thanks for the report. Tentatively accepting, however I'm not sure if we can sort these operations properly, we should probably alter unique_together first migrations.AlterUniqueTogether( name='authors', unique_together=set(), ), migrations.Re...
2022-05-27T13:20:14Z
4.2
["#23938 - Changing a ManyToManyField into a concrete field", "test_alter_unique_together_fk_to_m2m (migrations.test_autodetector.AutodetectorTests)"]
["#22030 - Adding a field with a default should work.", "#22275 - A migration with circular FK dependency does not try", "#22300 - Adding an FK in the same \"spot\" as a deleted CharField should", "#22435 - Adding a ManyToManyField should not prompt for a default.", "#22951 -- Uninstantiated classes with deconstruct ar...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15742
7faf25d682b8e8f4fd2006eb7dfc71ed2a2193b7
diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py --- a/django/templatetags/i18n.py +++ b/django/templatetags/i18n.py @@ -5,7 +5,7 @@ from django.template.base import TokenType, render_value_in_context from django.template.defaulttags import token_kwargs from django.utils import translation -fro...
diff --git a/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py b/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py --- a/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py +++ b/tests/template_tests/syntax_tests/i18n/test_blocktranslate.py @@ -416,6 +416,22 @@ def test_i18n41(self): ...
Blocktranslate asvar escapes variables, but stores the result as str instance, leading to double escaping Description In the docs, this snippet is given as an example usage of blocktranslate with the asvar argument (here: ​https://docs.djangoproject.com/en/4.0/topics/i18n/translation/#blocktranslate-template-tag: {% ...
Hi Richard, thanks for the report. So this would be the way forward: ... assign a SafeString instance to prevent future escaping But it's not at all clear how feasible it would be to correctly mark the returned string as safe. Individual variables are run via render_value_in_context() which escapes them assuming autoes...
2022-05-29T04:13:49Z
4.2
["test_i18n_asvar_safestring (template_tests.syntax_tests.i18n.test_blocktranslate.I18nBlockTransTagTests)"]
["Error in translation file should not crash template rendering (#16516).", "Error in translation file should not crash template rendering (#18393).", "Escaping inside blocktranslate and translate works as if it was", "Python's %-formatting is properly escaped in blocktranslate, singular,", "Simple baseline behavior wi...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15766
be63c78760924e1335603c36babd0ad6cfaea3c4
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py --- a/django/db/backends/base/base.py +++ b/django/db/backends/base/base.py @@ -1,6 +1,7 @@ import _thread import copy import datetime +import logging import threading import time import warnings @@ -26,6 +27,8 @@ NO_DB_ALIAS = "__no_...
diff --git a/django/test/testcases.py b/django/test/testcases.py --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -59,6 +59,8 @@ from django.utils.version import PY310 from django.views.static import serve +logger = logging.getLogger("django.test") + __all__ = ( "TestCase", "TransactionTe...
Supporting robust on_commit handlers. Description (last modified by Josh Smeaton) I recently tracked down an issue in my application where some on_commit handlers didn't execute because one of the previous handlers raised an exception. There appears to be no way to execute on_commit handlers *robustly* as you'r...
Sounds reasonable. Please take into account that the current behavior is ​documented. Josh, Would you like to prepare a patch? I haven't got the time to put a patch together *right now* but I could do so in the near future. Consider tagging this as "easy pickings" for a budding contributor? I've started an easy picking...
2022-06-07T16:12:45Z
4.2
["A visualisation of the callback tree tested. Each node is expected to", "test_execute (test_utils.tests.CaptureOnCommitCallbacksTests)", "test_execute_recursive (test_utils.tests.CaptureOnCommitCallbacksTests)", "test_execute_robust (test_utils.tests.CaptureOnCommitCallbacksTests)", "test_no_arguments (test_utils.tes...
["An exception is setUp() is reraised after disable() is called.", "If outer transaction fails, no hooks from within it run.", "Overriding DATABASE_ROUTERS should update the base router.", "Overriding the FILE_UPLOAD_DIRECTORY_PERMISSIONS setting should be", "Overriding the FILE_UPLOAD_PERMISSIONS setting should be ref...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15789
d4d5427571b4bf3a21c902276c2a00215c2a37cc
diff --git a/django/utils/html.py b/django/utils/html.py --- a/django/utils/html.py +++ b/django/utils/html.py @@ -59,7 +59,7 @@ def escapejs(value): } -def json_script(value, element_id=None): +def json_script(value, element_id=None, encoder=None): """ Escape all the HTML/XML special characters with the...
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 @@ -1,6 +1,7 @@ import os from datetime import datetime +from django.core.serializers.json import DjangoJSONEncoder from django.test import SimpleTestCase from dja...
Add an encoder parameter to django.utils.html.json_script(). Description I have a use case where I want to customize the JSON encoding of some values to output to the template layer. It looks like django.utils.html.json_script is a good utility for that, however the JSON encoder is hardcoded to DjangoJSONEncoder. I t...
Sounds good, and yes, we should document django.utils.html.json_script(). ​PR I'll also add docs for json_script() soon ​PR
2022-06-23T08:59:04Z
4.2
["test_json_script_custom_encoder (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...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15790
c627226d05dd52aef59447dcfb29cec2c2b11b8a
diff --git a/django/core/checks/templates.py b/django/core/checks/templates.py --- a/django/core/checks/templates.py +++ b/django/core/checks/templates.py @@ -50,15 +50,15 @@ def check_string_if_invalid_is_string(app_configs, **kwargs): @register(Tags.templates) def check_for_template_tags_with_the_same_name(app_conf...
diff --git a/tests/check_framework/test_templates.py b/tests/check_framework/test_templates.py --- a/tests/check_framework/test_templates.py +++ b/tests/check_framework/test_templates.py @@ -158,6 +158,19 @@ def test_template_tags_with_same_library_name(self): [self.error_same_tags], ) +...
check_for_template_tags_with_the_same_name with libraries in TEMPLATES Description I didn't explore this thoroughly, but I think there might be an issue with the check_for_template_tags_with_the_same_name when you add a template tag library into TEMPLATES['OPTIONS']['librairies']. I'm getting an error like: (templat...
Thanks for the report. It's a bug in the new system check (see 004b4620f6f4ad87261e149898940f2dcd5757ef and #32987).
2022-06-23T11:02:06Z
4.2
["test_template_tags_same_library_in_installed_apps_libraries (check_framework.test_templates.CheckTemplateTagLibrariesWithSameName)"]
["Error if template loaders are specified and APP_DIRS is True.", "test_app_dirs_removed (check_framework.test_templates.CheckTemplateSettingsAppDirsTest)", "test_loaders_removed (check_framework.test_templates.CheckTemplateSettingsAppDirsTest)", "test_string_if_invalid_both_are_strings (check_framework.test_templates....
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15799
90d2f9f41671ef01c8e8e7b5648f95c9bf512aae
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 @@ -314,8 +314,12 @@ def formfield_for_manytomany(self, db_field, request, **kwargs): kwargs["queryset"] = queryset form_field = db_field...
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 @@ -273,6 +273,26 @@ class AdvisorAdmin(admin.ModelAdmin): "Hold down “Control”, or “Command” on a Mac, to select more than one.", ) + def test_m2m_wi...
SelectMultiple in ModelAdminForm display help text when allow_multiple_selected is False. Description In AdminForm Help text on render for SelectMultiple widget don't check, if widget.allow_multiple_selected = False. Widget himself on render checks it # django.forms.widgets rows 684-685 if self.allow_multiple_selecte...
rendered m2m field with allow_multiple_selected=False Thanks for the report. As far as I understand correctly, you have a subclass of SelectMultiple with allow_multiple_selected set to False, that's quite niche. However, I agree that we should check allow_multiple_selected in both places: django/contrib/admin/options.p...
2022-06-27T02:15:54Z
4.2
["test_m2m_widgets_no_allow_multiple_selected (admin_widgets.tests.AdminFormfieldForDBFieldTests)"]
["Ensure the user can only see their own cars in the foreign key dropdown.", "File widgets should render as a link when they're marked \"read only.\"", "Overriding the widget for DateTimeField doesn't overrides the default", "The autocomplete_fields, raw_id_fields, filter_vertical, and", "WARNING: This test doesn't use...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15957
f387d024fc75569d2a4a338bfda76cc2f328f627
diff --git a/django/db/models/fields/related_descriptors.py b/django/db/models/fields/related_descriptors.py --- a/django/db/models/fields/related_descriptors.py +++ b/django/db/models/fields/related_descriptors.py @@ -64,8 +64,10 @@ class Child(Model): """ from django.core.exceptions import FieldError -from django...
diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py --- a/tests/prefetch_related/tests.py +++ b/tests/prefetch_related/tests.py @@ -1908,3 +1908,67 @@ def test_nested_prefetch_is_not_overwritten_by_related_object(self): self.assertIs(Room.house.is_cached(self.room), True) wi...
Prefetch objects don't work with slices Description ​Prefetch() objects does not work with sliced querysets. For example the following code results in AssertionError: Cannot filter a query once a slice has been taken.: Category.objects.prefetch_related(Prefetch( 'post_set', queryset=Post.objects.all()[:3], to_attr...
It seems to me that #26565 ("Allow Prefetch query to use .values()") is related. Hi ludwik, #26565 is about a different issue. The only way we could support slices would be to extract it from the provided queryset to make it filterable again and apply it when in-memory joining. The prefect queryset would still have to ...
2022-08-13T06:18:25Z
4.2
["test_foreignkey_reverse (prefetch_related.tests.PrefetchLimitTests)", "test_m2m_forward (prefetch_related.tests.PrefetchLimitTests)", "test_m2m_reverse (prefetch_related.tests.PrefetchLimitTests)", "test_reverse_ordering (prefetch_related.tests.PrefetchLimitTests)"]
["A 'content_object' can be traversed with prefetch_related() and", "A m2m can be followed through another m2m.", "A m2m relation can be followed after a relation like ForeignKey that", "A m2m relation can be followed after going through the select_related", "A model (Bio) with a OneToOneField primary key (author) that...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15969
081871bc20cc8b28481109b8dcadc321e177e6be
diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py --- a/django/db/models/deletion.py +++ b/django/db/models/deletion.py @@ -1,9 +1,9 @@ from collections import Counter, defaultdict -from functools import partial +from functools import partial, reduce from itertools import chain -from operator i...
diff --git a/tests/delete_regress/models.py b/tests/delete_regress/models.py --- a/tests/delete_regress/models.py +++ b/tests/delete_regress/models.py @@ -90,6 +90,12 @@ class Location(models.Model): class Item(models.Model): version = models.ForeignKey(Version, models.CASCADE) location = models.ForeignKey(L...
Performance issues with `on_delete=models.SET_NULL` on large tables Description Hello, I have the following models configuration: Parent model Child model, with a parent_id foreign key to a Parent model, set with on_delete=models.SET_NULL Each Parent can have a lot of children, in my case roughly 30k. I'm starting to...
You are right that is an opportunity for an optimization when SET, SET_DEFAULT, or SET_NULL is used but I wonder if it's worth doing given db_on_delete support (see #21961) make things even better for this use case. In the meantime, I'll switch to on_delete=models.CASCADE, which in my case does the trick, but I was cur...
2022-08-18T01:11:18Z
4.2
["test_set_querycount (delete_regress.tests.SetQueryCountTests)"]
["Auto-created many-to-many through tables referencing a parent model are", "Cascade deletion works with ForeignKey.to_field set to non-PK.", "Deleting a proxy-of-proxy instance should bubble through to its proxy", "Deleting an instance of a concrete model should also delete objects", "Deleting the *proxy* instance bub...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15973
2480554dc4ada4ecf3f6a08e318735a2e50783f3
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -1422,7 +1422,7 @@ def _get_dependencies_for_foreign_key(app_label, model_name, field, project_stat dependencies = [(dep_app_label, d...
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -3585,6 +3585,52 @@ def test_create_with_through_model(self): changes, "testapp", 0, 3, model_name="author", name="publishers...
Defining the "through" model in a many-to-many field in another app causes "AttributeError: 'str' object has no attribute '_meta'" on migration Description I tried migrating my apps into the database, the three relevant apps are called: "fonte", "fonte_variavel" and "variavel". fonte and variavel models have a many-t...
I was able to reproduce the problem with your models. Moving the FonteVariavelModel model to the fonte app seems to work. Even if there's a bug in Django, as a workaround, why not simply move the model?
2022-08-19T18:10:02Z
4.2
["test_create_with_through_model_separate_apps (migrations.test_autodetector.AutodetectorTests)"]
["#22030 - Adding a field with a default should work.", "#22275 - A migration with circular FK dependency does not try", "#22300 - Adding an FK in the same \"spot\" as a deleted CharField should", "#22435 - Adding a ManyToManyField should not prompt for a default.", "#22951 -- Uninstantiated classes with deconstruct ar...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15993
71902e0d9f93670c4f93ff9d66095b0e571be74b
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 @@ -371,13 +371,12 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state): new_model = to_st...
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 @@ -1058,8 +1058,8 @@ def test_rename_model_with_m2m(self): Pony._meta.get_field("riders").remote_field.through.objects.count(), 2 ...
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).
​PR I fixed the patch and it is waiting for review. In afeafd60: Fixed #33201 -- Made RenameModel operation a noop for models with db_table.
2022-08-24T13:40:21Z
4.2
["test_rename_model_with_db_table_rename_m2m (migrations.test_operations.OperationTests)"]
["#23426 - RunSQL should accept parameters.", "#23426 - RunSQL should fail when a list of statements with an incorrect", "#24098 - Tests no-op RunPython operations.", "#24098 - Tests no-op RunSQL operations.", "#24282 - Model changes to a FK reverse side update the model", "A complex SeparateDatabaseAndState operation:...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15995
0701bb8e1f1771b36cdde45602ad377007e372b3
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 @@ -647,15 +647,6 @@ def __init__(self, instance): self.core_filters = {self.field.name: i...
diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py --- a/tests/many_to_one/tests.py +++ b/tests/many_to_one/tests.py @@ -758,6 +758,9 @@ def test_relation_unsaved(self): ) with self.assertRaisesMessage(ValueError, msg): th.child_set.count() + # The reverse foreign...
Too aggressive pk control in create_reverse_many_to_one_manager Description In the context of #19580, Django now requires an instance pk to even instanciate a related manager [7ba6ebe9149a]. Now I have a use case where I need to introspect the model used by a related manager (MyModel().related_set.model) and Django 4...
I think this worth doing, having get_queryset perform self._check_fk_val() should catch the currently tested .all() case as well. In the mean time I think you should be able to use MyModel._meta.get_field("related_set") for your introspection needs. Replying to Simon Charette: ... In the mean time I think you should be...
2022-08-24T18:55:30Z
4.2
["test_relation_unsaved (many_to_one.tests.ManyToOneTests)"]
["Model.save() invalidates stale ForeignKey relations after a primary key", "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.ManyToOn...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-15996
b30c0081d4d8a31ab7dc7f72a4c7099af606ef29
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 @@ -16,7 +16,7 @@ from django.db.migrations.operations.base import Operation from django.db.migrations.utils import COMPILED_REGEX_TYPE, RegexObject f...
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 @@ -413,6 +413,14 @@ def test_serialize_enum_flags(self): "(2, migrations.test_writer.IntFlagEnum['B'])], " "default=migrations.test_writer...
Support for serialization of combination of Enum flags. Description (last modified by Willem Van Onsem) If we work with a field: regex_flags = models.IntegerField(default=re.UNICODE | re.IGNORECASE) This is turned into a migration with: default=re.RegexFlag[None] This is due to the fact that the EnumSerializer ...
patch of the EnumSerializer
2022-08-25T04:49:14Z
4.2
["test_serialize_enum_flags (migrations.test_writer.WriterTests)"]
["#24155 - Tests ordering of imports.", "A reference in a local scope can't be serialized.", "An unbound method used within a class body can be serialized.", "Make sure compiled regex can be serialized.", "Test comments at top of file.", "Tests serializing a simple migration.", "Ticket #22679: makemigrations generates ...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16032
0c3981eb5094419fe200eb46c71b5376a2266166
diff --git a/django/db/models/fields/related_lookups.py b/django/db/models/fields/related_lookups.py --- a/django/db/models/fields/related_lookups.py +++ b/django/db/models/fields/related_lookups.py @@ -93,7 +93,6 @@ def get_prep_lookup(self): elif not getattr(self.rhs, "has_select_fields", True) and not g...
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -989,6 +989,34 @@ def test_annotation_filter_with_subquery(self): publisher_books_qs, [{"name": "Sams"}, {"name": "Morgan Kaufmann"}] ) + def test_annotati...
__in doesn't clear selected fields on the RHS when QuerySet.alias() is used after annotate(). Description Here is a test case to reproduce the bug, you can add this in tests/annotations/tests.py def test_annotation_and_alias_filter_in_subquery(self): long_books_qs = ( Book.objects.filter( pages__gt=400, ...
This is a ​documented and expected behavior. Using either .alias or .annotate works as expected without using .values to limit to 1 column. Why is that? but using both of them doesn't seem work. Replying to Gabriel Muj: Using either .alias or .annotate works as expected without using .values to limit to 1 column. Why i...
2022-09-06T09:54:57Z
4.2
["test_annotation_and_alias_filter_in_subquery (annotations.tests.NonAggregateAnnotationTestCase)", "test_annotation_and_alias_filter_related_in_subquery (annotations.tests.NonAggregateAnnotationTestCase)"]
["Annotating None onto a model round-trips", "Annotations can reference fields in a values clause,", "Columns are aligned in the correct order for resolve_columns. This test", "Deferred attributes can be referenced by an annotation,", "Fields on an inherited model can be referenced by an", "test_aggregate_alias (annota...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16076
cfe3008123ed7c9e3f3a4d51d4a22f9d96634e33
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 @@ -1278,10 +1278,6 @@ def build_lookup(self, lookups, lhs, rhs): # supports both transform and lookup for the name. lookup_class = lhs.get_lookup(lookup_n...
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py --- a/tests/lookup/tests.py +++ b/tests/lookup/tests.py @@ -786,10 +786,16 @@ def test_unsupported_lookups(self): def test_relation_nested_lookup_error(self): # An invalid nested lookup on a related field raises a useful error. - msg = "R...
Registering lookups on relation fields should be supported. Description (last modified by Thomas) Hello, I have a model, let's call it Parent, with a field called object_id. I have another model, let's call it Child, which has a ForeignKey field called parent_object[_id] pointing to Parent.object_id. I need to ...
Thanks for the report. Django 4.2 (cd1afd553f9c175ebccfc0f50e72b43b9604bd97) allows ​registering lookups per field instances, so you will be able to register __startswith for parent_object_id, e.g. parent_field = Child._meta.get_field("parent_object_id") with register_lookup(parent_field, StartsWith): Child.objects.fil...
2022-09-20T11:42:13Z
4.2
["test_filter_by_related_field_transform (queries.tests.Queries1Tests)", "test_relation_nested_lookup_error (lookup.tests.LookupTests)"]
["A ValueError is raised when the incorrect object type is passed to a", "A lookup query containing non-fields raises the proper exception.", "A regex lookup does not fail on non-string fields", "A regex lookup does not fail on null/None values", "A regex lookup does not trip on non-ASCII characters.", "Can create an i...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16111
f71b0cf769d9ac582ee3d1a8c33d73dad3a770da
diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py --- a/django/db/backends/mysql/features.py +++ b/django/db/backends/mysql/features.py @@ -81,7 +81,7 @@ def test_collations(self): "swedish_ci": f"{charset}_swedish_ci", } - test_now_utc_template = "UTC_T...
diff --git a/tests/db_functions/datetime/test_now.py b/tests/db_functions/datetime/test_now.py --- a/tests/db_functions/datetime/test_now.py +++ b/tests/db_functions/datetime/test_now.py @@ -1,6 +1,8 @@ from datetime import datetime, timedelta -from django.db.models.functions import Now +from django.db import connec...
Add support for microseconds to Now() on MySQL and SQLite. Description Add support for microseconds to Now() on MySQL and SQLite. ​PR
null
2022-09-25T12:33:08Z
4.2
["test_microseconds (db_functions.datetime.test_now.NowTests)"]
["test_basic (db_functions.datetime.test_now.NowTests)"]
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16116
5d36a8266c7d5d1994d7a7eeb4016f80d9cb0401
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -70,7 +70,10 @@ def add_arguments(self, parser): "--check", acti...
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -2391,9 +2391,10 @@ def test_makemigrations_check(self): makemigrations --check should exit with a non-zero status when there are change...
makemigrations --check generating migrations is inconsistent with other uses of --check Description To script a check for missing migrations but without actually intending to create the migrations, it is necessary to use both --check and --dry-run, which is inconsistent with migrate --check and optimizemigration --ch...
I think this makes sense.
2022-09-25T23:54:49Z
4.2
["makemigrations --check should exit with a non-zero status when"]
["--fake-initial only works if all tables created in the initial", "--squashed-name also works if a start migration is omitted.", "--squashed-name specifies the new migration's name.", "Allow `makemigrations --dry-run` to output the migrations file to", "Assuming you have 3 apps, `A`, `B`, and `C`, such that:", "For an...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16136
19e6efa50b603af325e7f62058364f278596758f
diff --git a/django/views/generic/base.py b/django/views/generic/base.py --- a/django/views/generic/base.py +++ b/django/views/generic/base.py @@ -148,7 +148,16 @@ def http_method_not_allowed(self, request, *args, **kwargs): request.path, extra={"status_code": 405, "request": request}, ...
diff --git a/tests/async/tests.py b/tests/async/tests.py --- a/tests/async/tests.py +++ b/tests/async/tests.py @@ -6,8 +6,8 @@ from django.core.cache import DEFAULT_CACHE_ALIAS, caches from django.core.exceptions import ImproperlyConfigured, SynchronousOnlyOperation -from django.http import HttpResponse -from djang...
object HttpResponseNotAllowed can't be used in 'await' expression Description When defining a simple View subclass with only an async "post" method, GET requests to this view cause the following exception: [29/Sep/2022 07:50:48] "GET /demo HTTP/1.1" 500 81134 Method Not Allowed (GET): /demo Internal Server Error: /de...
Yes, looks right. http_method_not_allowed() needs to be adjusted to handle both sync and async cases in the same way as options() Do you have capacity to do a patch quickly? (Otherwise I'll take it on.) Thanks for the report! Regression in 9ffd4eae2ce7a7100c98f681e2b6ab818df384a4. Thank you very much for your confirmat...
2022-09-29T11:47:50Z
4.2
["test_http_method_not_allowed_responds_correctly (async.tests.ViewTests)", "test_mixed_views_raise_error (async.tests.ViewTests)"]
["Utility class which turns an awaitable that only works on the thread with", "View and by extension any subclasses that don't define handlers are", "test_async_unsafe (async.tests.AsyncUnsafeTest)", "test_caches_local (async.tests.CacheTest)", "test_get_async_connection (async.tests.DatabaseConnectionTest)", "test_opt...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16254
e580b891cb5ae31eb0571c88428afb9bf69e47f2
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 @@ -379,7 +379,10 @@ def delete_model(self, model, handle_autom2m=True): def add_field(self, model, field): """Create a field on ...
diff --git a/tests/schema/tests.py b/tests/schema/tests.py --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -2200,8 +2200,25 @@ class Meta: with self.assertRaises(DatabaseError): self.column_classes(new_field.remote_field.through) # Add the field - with connection.schema_...
Adding ManyToManyField on SQLite rebuilds table. Description Hey there, While updating the ​django-migration-linter for Django 4.1 (yeah, a bit late to the party, but I was busy eh :P), I bumped into what seems to be a regression. On SQLite, when adding a ManyToManyField to a table, it seems to rebuild the table - wh...
null
2022-11-04T04:58:15Z
4.2
["test_m2m (schema.tests.SchemaTests)", "test_m2m_custom (schema.tests.SchemaTests)", "test_m2m_inherited (schema.tests.SchemaTests)"]
["#23065 - Constraint names must be quoted if they contain capital letters.", "#23609 - Tests handling of default values when altering from NULL to NOT NULL.", "#23738 - Can change a nullable field with default to non-nullable", "#23987 - effective_default() should be used as the field default when", "#24163 - Tests al...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16256
76e37513e22f4d9a01c7f15eee36fe44388e6670
diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -2,6 +2,8 @@ import itertools from collections import defaultdict +from asgiref.sync import sync_to_async + from django.contrib.conte...
diff --git a/tests/async/models.py b/tests/async/models.py --- a/tests/async/models.py +++ b/tests/async/models.py @@ -9,3 +9,7 @@ class RelatedModel(models.Model): class SimpleModel(models.Model): field = models.IntegerField() created = models.DateTimeField(default=timezone.now) + + +class ManyToManyModel(m...
acreate(), aget_or_create(), and aupdate_or_create() doesn't work as intended on related managers. Description Async-compatible interface was added to QuerySet in 58b27e0dbb3d31ca1438790870b2b51ecdb10500. Unfortunately, it also added (unintentionally) async acreate(), aget_or_create(), and aupdate_or_create() methods...
Jon, would you like to prepare a patch? (against the main branch.) Yeah I can take care of that. I’ll be traveling for the next 2 days then recovering from jetlag and then back on the road again, so I just want to set expectations that this won’t be immediate :( Replying to Jon Janzen: Yeah I can take care of that. I’l...
2022-11-04T14:26:44Z
4.2
["test_acreate (async.test_async_related_managers.AsyncRelatedManagersOperationTest)", "test_acreate_reverse (async.test_async_related_managers.AsyncRelatedManagersOperationTest)", "test_aget_or_create (async.test_async_related_managers.AsyncRelatedManagersOperationTest)", "test_aget_or_create_reverse (async.test_async...
["Concrete model subclasses with generic relations work", "Create another fatty tagged instance with different PK to ensure there", "Generic relations on a base class (Vegetable) work correctly in", "If Generic Relation is not explicitly defined, any related objects", "If you delete a tag, the objects using the tag are...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5
django/django
django__django-16260
444b6da7cc229a58a2c476a52e45233001dc7073
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 @@ -737,6 +737,11 @@ def refresh_from_db(self, using=None, fields=None): if field.is_cached(self): field.delete_cached_value(self) + # Clear cached privat...
diff --git a/tests/contenttypes_tests/test_fields.py b/tests/contenttypes_tests/test_fields.py --- a/tests/contenttypes_tests/test_fields.py +++ b/tests/contenttypes_tests/test_fields.py @@ -43,6 +43,14 @@ def test_get_object_cache_respects_deleted_objects(self): self.assertIsNone(post.parent) ...
model.refresh_from_db() doesn't clear cached generic foreign keys Description (last modified by pascal chambon) In my code, Users have a generic foreign key like so: controlled_entity_content_type = models.ForeignKey(ContentType, blank=True, null=True, on_delete=models.CASCADE) controlled_entity_object_id = ...
Thanks for the report. Bonjour Pascal, It seems to be an oversight in Model.refresh_from_db as it should also consider _meta.private_fields which is where GenericForeignKey and GenericRel end up as opposed to related_objects. Something along these lines should address the issue django/db/models/base.py diff --git a/dja...
2022-11-05T17:49:31Z
4.2
["test_clear_cached_generic_relation (contenttypes_tests.test_fields.GenericForeignKeyTests)"]
["test_get_content_type_no_arguments (contenttypes_tests.test_fields.GenericForeignKeyTests)", "test_get_object_cache_respects_deleted_objects (contenttypes_tests.test_fields.GenericForeignKeyTests)", "test_incorrect_get_prefetch_queryset_arguments (contenttypes_tests.test_fields.GenericForeignKeyTests)", "test_str (co...
0fbdb9784da915fce5dcc1fe82bac9b4785749e5