repo stringclasses 1
value | instance_id stringlengths 20 20 | base_commit stringlengths 40 40 | patch stringlengths 397 10.8k | test_patch stringlengths 542 11.2k | problem_statement stringlengths 190 6.76k | hints_text stringlengths 0 13.8k | created_at stringdate 2018-06-26 23:30:51 2023-07-17 20:28:41 | version stringclasses 8
values | FAIL_TO_PASS stringlengths 39 32.6k | PASS_TO_PASS stringlengths 2 107k | environment_setup_commit stringclasses 8
values | difficulty stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
django/django | django__django-10097 | b9cf764be62e77b4777b3a75ec256f6209a57671 | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -94,7 +94,7 @@ class URLValidator(RegexValidator):
regex = _lazy_re_compile(
r'^(?:[a-z0-9\.\-\+]*)://' # scheme is validated separately
- r'(?:\S+(?::\S*)?@)?' ... | diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
--- a/tests/validators/invalid_urls.txt
+++ b/tests/validators/invalid_urls.txt
@@ -57,3 +57,9 @@ http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | Make URLValidator reject invalid characters in the username and password
Description
(last modified by Tim Bell)
Since #20003, core.validators.URLValidator accepts URLs with usernames and passwords. RFC 1738 section 3.1 requires "Within the user and password field, any ":", "@", or "/" must be encoded"; however... | 2018-06-26T23:30:51Z | 2.2 | ["test_ascii_validator (auth_tests.test_validators.UsernameValidatorsTests)", "test_unicode_validator (auth_tests.test_validators.UsernameValidatorsTests)", "test_help_text (auth_tests.test_validators.UserAttributeSimilarityValidatorTest)", "test_validate (auth_tests.test_validators.UserAttributeSimilarityValidatorTest... | ["test_defaults (str.tests.SimpleTests)", "test_international (str.tests.SimpleTests)", "test_default (model_fields.test_decimalfield.DecimalFieldTests)", "test_filter_with_strings (model_fields.test_decimalfield.DecimalFieldTests)", "test_get_prep_value (model_fields.test_decimalfield.DecimalFieldTests)", "test_lookup... | 4fc35a9c3efdc9154efce28cb23cb84f8834517e | <15 min fix | |
django/django | django__django-10914 | e7fd69d051eaa67cb17f172a39b57253e9cb831a | diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -304,7 +304,7 @@ def gettext_noop(s):
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https:/... | diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1099,7 +1099,7 @@ def test_override_file_upload_permissions(self):
the file_permissions_mode attribute of
django.core.files.storage.default_storage.
"""
- ... | Set default FILE_UPLOAD_PERMISSION to 0o644.
Description
Hello,
As far as I can see, the File Uploads documentation page does not mention any permission issues.
What I would like to see is a warning that in absence of explicitly configured FILE_UPLOAD_PERMISSIONS, the permissions for a file uploaded to FileSystemSto... | I think you're talking about ef70af77ec53160d5ffa060c1bdf5ed93322d84f (#28540). I guess the question is whether or not that documentation should be duplicated elsewhere.
Thank you Tim, this is precisely what I was looking for! I can only see one issue with the current docs (if you excuse me for bothering you with such ... | 2019-01-30T13:13:20Z | 3.0 | ["test_override_file_upload_permissions (test_utils.tests.OverrideSettingsTests)"] | ["test_allowed_database_chunked_cursor_queries (test_utils.tests.AllowedDatabaseQueriesTests)", "test_allowed_database_queries (test_utils.tests.AllowedDatabaseQueriesTests)", "test_skip_if_db_feature (test_utils.tests.SkippingTestCase)", "test_skip_unless_db_feature (test_utils.tests.SkippingTestCase)", "test_equal_pa... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11066 | 4b45b6c8e4d7c9701a332e80d3b1c84209dc36e2 | diff --git a/django/contrib/contenttypes/management/__init__.py b/django/contrib/contenttypes/management/__init__.py
--- a/django/contrib/contenttypes/management/__init__.py
+++ b/django/contrib/contenttypes/management/__init__.py
@@ -24,7 +24,7 @@ def _rename(self, apps, schema_editor, old_model, new_model):
... | diff --git a/tests/contenttypes_tests/test_operations.py b/tests/contenttypes_tests/test_operations.py
--- a/tests/contenttypes_tests/test_operations.py
+++ b/tests/contenttypes_tests/test_operations.py
@@ -14,11 +14,16 @@
),
)
class ContentTypeOperationsTests(TransactionTestCase):
+ databases = {'default', '... | RenameContentType._rename() doesn't save the content type on the correct database
Description
The commit in question:
https://github.com/django/django/commit/f179113e6cbc8ba0a8d4e87e1d4410fb61d63e75
The specific lines in question:
https://github.com/django/django/blob/586a9dc4295357de1f5ad0590ad34bf2bc008f79/django... | Added a pull request with the fix. https://github.com/django/django/pull/10332
Hi, I spent all afternoon into this ticket. As I am a newbie I failed to make a test for it. And the fix can really be 'using=db' in the .save() method. But I found a StackOverflow answer about transaction.atomic(using=db) that is interesti... | 2019-03-09T13:03:14Z | 3.0 | ["test_existing_content_type_rename_other_database (contenttypes_tests.test_operations.ContentTypeOperationsTests)"] | ["test_content_type_rename_conflict (contenttypes_tests.test_operations.ContentTypeOperationsTests)", "test_existing_content_type_rename (contenttypes_tests.test_operations.ContentTypeOperationsTests)", "test_missing_content_type_rename_ignore (contenttypes_tests.test_operations.ContentTypeOperationsTests)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11095 | 7d49ad76562e8c0597a0eb66046ab423b12888d8 | 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
@@ -327,6 +327,10 @@ def get_fieldsets(self, request, obj=None):
return self.fieldsets
return [(None, {'fields': self.get_fields(request, obj)}... | diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -429,3 +429,29 @@ class EpisodeAdmin(admin.ModelAdmin):
inlines = ma.get_inline_instances(request)
for (formset, inline), other_... | add ModelAdmin.get_inlines() hook to allow set inlines based on the request or model instance.
Description
add ModelAdmin.get_inlines() hook to allow set inlines based on the request or model instance.
Currently, We can override the method get_inline_instances to do such a thing, but a for loop should be copied to my... | Are you going to offer a patch to show exactly what you have in mind? I'm not immediately convinced that another hook is needed since the cost of duplicating a for loop is not that great.
If I want to realize a dynamic inlines based on the request or model instance. I need to override get_inline_instances to do it. Wha... | 2019-03-19T15:17:28Z | 3.0 | ["test_get_inline_instances_override_get_inlines (generic_inline_admin.tests.GenericInlineModelAdminTest)"] | ["test_no_deletion (generic_inline_admin.tests.NoInlineDeletionTest)", "test_custom_form_meta_exclude (generic_inline_admin.tests.GenericInlineModelAdminTest)", "test_custom_form_meta_exclude_with_readonly (generic_inline_admin.tests.GenericInlineModelAdminTest)", "test_get_fieldsets (generic_inline_admin.tests.Generic... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11119 | d4df5e1b0b1c643fe0fc521add0236764ec8e92a | diff --git a/django/template/engine.py b/django/template/engine.py
--- a/django/template/engine.py
+++ b/django/template/engine.py
@@ -160,7 +160,7 @@ def render_to_string(self, template_name, context=None):
if isinstance(context, Context):
return t.render(context)
else:
- retu... | diff --git a/tests/template_tests/test_engine.py b/tests/template_tests/test_engine.py
--- a/tests/template_tests/test_engine.py
+++ b/tests/template_tests/test_engine.py
@@ -21,6 +21,13 @@ def test_basic_context(self):
'obj:test\n',
)
+ def test_autoescape_off(self):
+ engine = Engine... | Engine.render_to_string() should honor the autoescape attribute
Description
In Engine.render_to_string, a Context is created without specifying the engine autoescape attribute. So if you create en engine with autoescape=False and then call its render_to_string() method, the result will always be autoescaped. It was p... | I'd like to reserve this for an event I'll attend on Oct 4th. | 2019-03-24T21:17:05Z | 3.0 | ["test_autoescape_off (template_tests.test_engine.RenderToStringTest)"] | ["test_cached_loader_priority (template_tests.test_engine.LoaderTests)", "test_loader_priority (template_tests.test_engine.LoaderTests)", "test_origin (template_tests.test_engine.LoaderTests)", "test_basic_context (template_tests.test_engine.RenderToStringTest)", "test_multiple_engines_configured (template_tests.test_e... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11206 | 571ab44e8a8936014c22e7eebe4948d9611fd7ce | diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
--- a/django/utils/numberformat.py
+++ b/django/utils/numberformat.py
@@ -27,6 +27,14 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
# sign
sign = ''
if isinstance(number, Decimal):
+
+ if d... | diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py
--- a/tests/utils_tests/test_numberformat.py
+++ b/tests/utils_tests/test_numberformat.py
@@ -94,7 +94,7 @@ def test_decimal_numbers(self):
('1e-10', 8, '0.00000000'),
('1e-11', 8, '0.00000000'),
... | utils.numberformat.format renders small decimals in exponential notation.
Description
When using utils.number_format with decimal_pos, extremely small numbers get displayed using exponential notation.
>>> from django.utils.numberformat import format as nformat
>>> nformat(Decimal('1e-199'), '.', decimal_pos=2)
'0.00'... | Hi Sjoerd. OK, so this is related to the changes in 9cc6a60040b0f64f8ea066dd215176d4bd16621d. Happy to Accept as a potential Cleanup/optimization — I guess ultimately it depends on what the change looks like. (i.e. is the nicer behaviour worth the extra complexity? etc) I'm assuming you're ready/willing to make the pat... | 2019-04-13T10:19:38Z | 3.0 | ["test_decimal_numbers (utils_tests.test_numberformat.TestNumberFormat)", "test_decimal_subclass (utils_tests.test_numberformat.TestNumberFormat)"] | ["test_float_numbers (utils_tests.test_numberformat.TestNumberFormat)", "test_format_number (utils_tests.test_numberformat.TestNumberFormat)", "test_format_string (utils_tests.test_numberformat.TestNumberFormat)", "test_large_number (utils_tests.test_numberformat.TestNumberFormat)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11211 | ba726067604ce5a8ca3919edf653496722b433ab | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -2325,6 +2325,10 @@ def deconstruct(self):
def get_internal_type(self):
return "UUIDField"
+ def get_prep_value(self, value):
+... | diff --git a/tests/prefetch_related/models.py b/tests/prefetch_related/models.py
--- a/tests/prefetch_related/models.py
+++ b/tests/prefetch_related/models.py
@@ -172,6 +172,11 @@ def __str__(self):
return self.tag
+class Article(models.Model):
+ id = models.UUIDField(primary_key=True, default=uuid.uuid... | Prefetch related is not working when used GFK for model that uses UUID field as PK.
Description
How to reproduce:
create model with UUID as primary key
class Foo(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
...
create another model with GFK to model Foo
class Bar(models... | Thanks for the report, however GenericForeignKey doesn't support prefetch_related(), from the same reason it doesn't not support also filter(), exclude(), etc. Please see documentation. | 2019-04-13T12:01:14Z | 3.0 | ["test_prefetch_GFK_uuid_pk (prefetch_related.tests.GenericRelationTests)"] | ["test_bug (prefetch_related.tests.Ticket21410Tests)", "test_basic (prefetch_related.tests.RawQuerySetTests)", "test_clear (prefetch_related.tests.RawQuerySetTests)", "test_prefetch_before_raw (prefetch_related.tests.RawQuerySetTests)", "test_bug (prefetch_related.tests.Ticket19607Tests)", "test_m2m_then_m2m (prefetch_... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11239 | d87bd29c4f8dfcdf3f4a4eb8340e6770a2416fe3 | diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -17,6 +17,10 @@ def runshell_db(cls, conn_params):
dbname = conn_params.get('database', '')
user = conn_params.g... | diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py
--- a/tests/dbshell/test_postgresql.py
+++ b/tests/dbshell/test_postgresql.py
@@ -14,15 +14,16 @@ def _run_it(self, dbinfo):
That function invokes the runshell command, while mocking
subprocess.run(). It returns a 2-tuple... | Add support for postgresql client certificates and key to dbshell.
Description
This bug is very similar to the #28322
A common security procedure for DB access is to require mutual TLS for the DB connection.
This involves specifying a server certificate, client certificate, and client key when connecting.
Django alre... | 2019-04-16T09:44:54Z | 3.0 | ["test_ssl_certificate (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)"] | ["test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_column (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_nopass (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "SIGINT is ignored in Py... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11265 | 21aa2a5e785eef1f47beb1c3760fdd7d8915ae09 | 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
@@ -1666,6 +1666,7 @@ def split_exclude(self, filter_expr, can_reuse, names_with_path):
filter_expr = (filter_lhs, OuterRef(filter_rhs.name))
# Generat... | diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py
--- a/tests/filtered_relation/tests.py
+++ b/tests/filtered_relation/tests.py
@@ -98,6 +98,14 @@ def test_with_join(self):
[self.author1]
)
+ def test_with_exclude(self):
+ self.assertSequenceEqual(
+ ... | Using exclude on annotated FilteredRelation doesn't work
Description
It looks like using exclude on queryset with annotated FilteredRelation give a FieldError on the annotation name.
For exemple, in Django tests (django/tests/filtered_relation/tests.py) if we change this :
def test_with_join(self):
self.assertSequen... | I've submitted a PR: PR
Patch looks good but it looks like doesn't qualify for a backport given FilteredRelation was introduced in Django 2.0 and isn't considered a new feature at this point.
Hi, i've tested the solution you're giving in your PR but it doesn't seams to be ok, let me explain. Even if the error is not t... | 2019-04-21T12:57:28Z | 3.0 | ["test_with_exclude (filtered_relation.tests.FilteredRelationTests)"] | ["test_aggregate (filtered_relation.tests.FilteredRelationAggregationTests)", "test_as_subquery (filtered_relation.tests.FilteredRelationTests)", "test_defer (filtered_relation.tests.FilteredRelationTests)", "test_difference (filtered_relation.tests.FilteredRelationTests)", "test_exclude_relation_with_join (filtered_re... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11333 | 55b68de643b5c2d5f0a8ea7587ab3b2966021ccc | diff --git a/django/urls/base.py b/django/urls/base.py
--- a/django/urls/base.py
+++ b/django/urls/base.py
@@ -7,7 +7,7 @@
from django.utils.translation import override
from .exceptions import NoReverseMatch, Resolver404
-from .resolvers import get_ns_resolver, get_resolver
+from .resolvers import _get_cached_resol... | diff --git a/tests/urlpatterns/test_resolvers.py b/tests/urlpatterns/test_resolvers.py
--- a/tests/urlpatterns/test_resolvers.py
+++ b/tests/urlpatterns/test_resolvers.py
@@ -1,5 +1,6 @@
from django.test import SimpleTestCase
-from django.urls.resolvers import RegexPattern, RoutePattern
+from django.test.utils import ... | Optimization: Multiple URLResolvers may be unintentionally be constructed by calls to `django.urls.resolvers.get_resolver`
Description
Multiple URLResolvers may be constructed by django.urls.resolvers.get_resolver if django.urls.base.set_urlconf has not yet been called, resulting in multiple expensive calls to URLRes... | I'm planning to contribute a fix, as soon as I can get the CLA signed. Hi. Great. Happy to provisionally Accept this pending how the patch looks. (Sounds fine in principle.) Welcome on-board! :) | 2019-05-06T21:00:53Z | 3.0 | ["test_resolver_cache_default__root_urlconf (urlpatterns.test_resolvers.ResolverCacheTests)"] | ["test_str (urlpatterns.test_resolvers.RegexPatternTests)", "test_str (urlpatterns.test_resolvers.RoutePatternTests)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11433 | 21b1d239125f1228e579b1ce8d94d4d5feadd2a6 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -48,8 +48,11 @@ def construct_instance(form, instance, fields=None, exclude=None):
continue
# Leave defaults for fields that aren't in POST data, except for
# checkbox... | diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -585,6 +585,32 @@ class Meta:
m2 = mf2.save(commit=False)
self.assertEqual(m2.mode, '')
+ def test_default_not_populated_on_non_empty_value_in_cleaned_data(sel... | Allow `cleaned_data` to overwrite fields' default values.
Description
See comments here: https://github.com/django/django/pull/7068/files#r289432409
Currently, when submitting a form, if 'some_field' isn't in the data payload (e.g. it wasn't included in the form, perhaps because its value is derived from another fie... | 2019-05-31T17:06:20Z | 3.0 | ["test_default_not_populated_on_non_empty_value_in_cleaned_data (model_forms.tests.ModelFormBaseTest)"] | ["test_model_form_clean_applies_to_model (model_forms.tests.CustomCleanTests)", "test_override_clean (model_forms.tests.CustomCleanTests)", "test_model_form_applies_localize_to_all_fields (model_forms.tests.LocalizedModelFormTest)", "test_model_form_applies_localize_to_some_fields (model_forms.tests.LocalizedModelFormT... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11477 | e28671187903e6aca2428374fdd504fca3032aee | diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -153,7 +153,7 @@ def match(self, path):
# If there are any named groups, use those as kwargs, ignoring
# non-named groups. Otherwise, pass all non-named arguments a... | diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -158,6 +158,15 @@ def test_translate_url_utility(self):
# path() URL pattern
self.assertEqual(translate_url('/en/account/register-as-path/', 'nl'), ... | translate_url() creates an incorrect URL when optional named groups are missing in the URL pattern
Description
There is a problem when translating urls with absent 'optional' arguments
(it's seen in test case of the patch)
| Could you please provide the patch as a pull request against master? Unless this is a regression, it probably doesn't qualify for a backport to 1.9 (see our supported versions policy). Please check the patch on Python 3 as well (dict.iteritems() doesn't exist there).
The issue here is that resolve() will return None f... | 2019-06-14T17:40:45Z | 3.0 | ["test_re_path_with_optional_parameter (urlpatterns.tests.SimplifiedURLTests)", "test_two_variable_at_start_of_path_pattern (urlpatterns.tests.SimplifiedURLTests)", "test_translate_url_utility (i18n.patterns.tests.URLTranslationTests)"] | ["test_include_2_tuple (urlpatterns_reverse.tests.IncludeTests)", "test_include_2_tuple_namespace (urlpatterns_reverse.tests.IncludeTests)", "test_include_3_tuple (urlpatterns_reverse.tests.IncludeTests)", "test_include_3_tuple_namespace (urlpatterns_reverse.tests.IncludeTests)", "test_include_4_tuple (urlpatterns_reve... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11532 | a5308514fb4bc5086c9a16a8a24a945eeebb073c | diff --git a/django/core/mail/message.py b/django/core/mail/message.py
--- a/django/core/mail/message.py
+++ b/django/core/mail/message.py
@@ -16,7 +16,7 @@
from django.conf import settings
from django.core.mail.utils import DNS_NAME
-from django.utils.encoding import force_str
+from django.utils.encoding import fo... | diff --git a/tests/mail/tests.py b/tests/mail/tests.py
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -14,10 +14,11 @@
from io import StringIO
from smtplib import SMTP, SMTPAuthenticationError, SMTPException
from ssl import SSLError
+from unittest import mock
from django.core import mail
from django.core... | Email messages crash on non-ASCII domain when email encoding is non-unicode.
Description
When the computer hostname is set in unicode (in my case "正宗"), the following test fails: https://github.com/django/django/blob/master/tests/mail/tests.py#L368
Specifically, since the encoding is set to iso-8859-1, Python attemp... | Thanks for the report. Simple encoding should fix this issue, e.g. diff --git a/django/core/mail/utils.py b/django/core/mail/utils.py index d18dfe4667..68f9e464d6 100644 --- a/django/core/mail/utils.py +++ b/django/core/mail/utils.py @@ -14,6 +14,10 @@ class CachedDnsName: def get_fqdn(self): if not hasattr(self, '_fqd... | 2019-07-02T10:29:28Z | 3.0 | ["test_non_ascii_dns_non_unicode_email (mail.tests.MailTests)"] | ["test_7bit (mail.tests.PythonGlobalState)", "test_8bit_latin (mail.tests.PythonGlobalState)", "test_8bit_non_latin (mail.tests.PythonGlobalState)", "test_utf8 (mail.tests.PythonGlobalState)", "test_date_header_localtime (mail.tests.MailTimeZoneTests)", "test_date_header_utc (mail.tests.MailTimeZoneTests)", "test_close... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11555 | 8dd5877f58f84f2b11126afbd0813e24545919ed | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -722,6 +722,9 @@ def find_ordering_name(self, name, opts, alias=None, default_order='ASC',
results = []
for item in opts.ordering:... | diff --git a/tests/ordering/models.py b/tests/ordering/models.py
--- a/tests/ordering/models.py
+++ b/tests/ordering/models.py
@@ -54,6 +54,10 @@ class Meta:
ordering = (models.F('author').asc(nulls_first=True), 'id')
+class ChildArticle(Article):
+ pass
+
+
class Reference(models.Model):
article ... | order_by() a parent model crash when Meta.ordering contains expressions.
Description
(last modified by Jonny Fuller)
Hi friends,
During testing I discovered a strange bug when using a query expression for ordering during multi-table inheritance. You can find the full write up as well as reproducible test reposi... | Thanks for the report. I attached a regression test. Reproduced at c498f088c584ec3aff97409fdc11b39b28240de9.
Regression test.
I *think* I'm getting a similar (or same) error when adding lowercased ordering to a model via meta: class Recipe(models.Model): # ... class Meta: ordering = (Lower('name'),) This works fine in ... | 2019-07-10T18:07:07Z | 3.0 | ["test_order_by_ptr_field_with_default_ordering_by_expression (ordering.tests.OrderingTests)"] | ["test_default_ordering (ordering.tests.OrderingTests)", "F expressions can be used in Meta.ordering.", "test_default_ordering_override (ordering.tests.OrderingTests)", "test_deprecated_values_annotate (ordering.tests.OrderingTests)", "test_extra_ordering (ordering.tests.OrderingTests)", "test_extra_ordering_quoting (o... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11740 | 003bb34b218adb23d1a7e67932a6ba9b3c4dcc81 | 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
@@ -912,6 +912,7 @@ def generate_altered_fields(self):
old_field_name = self.renamed_fields.get((app_label, model_name, field_name),... | 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
@@ -352,6 +352,11 @@ class AutodetectorTests(TestCase):
("author", models.ForeignKey("migrations.UnmigratedModel", models.CASCADE)),... | Change uuid field to FK does not create dependency
Description
(last modified by Simon Charette)
Hi! I am new in django community, so please help me, because i really dont know is it really "bug".
I have a django project named "testproject" and two apps: testapp1, testapp2.
It will be simpler to understand, wit... | Django project which show the bug
There's a lot of history in here, so it may turn out this is a duplicate, but I'll accept this for now, as there's certainly a bug. makemigrations generats this: dependencies = [ ('testapp1', '0002_app1_another_app'), ] operations = [ migrations.AlterField( model_name='app1', name='ano... | 2019-09-03T10:44:38Z | 3.0 | ["test_alter_field_to_fk_dependency_other_app (migrations.test_autodetector.AutodetectorTests)"] | ["test_add_alter_order_with_respect_to (migrations.test_autodetector.AutodetectorTests)", "test_add_blank_textfield_and_charfield (migrations.test_autodetector.AutodetectorTests)", "Test change detection of new constraints.", "test_add_date_fields_with_auto_now_add_asking_for_default (migrations.test_autodetector.Autod... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11749 | 350123f38c2b6217c38d70bfbd924a9ba3df1289 | 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
@@ -130,11 +130,19 @@ def get_actions(parser):
yield opt
parser_actions = list(get_actions(parser))
+ mutually_exclusive_requi... | diff --git a/tests/user_commands/management/commands/mutually_exclusive_required.py b/tests/user_commands/management/commands/mutually_exclusive_required.py
new file mode 100644
--- /dev/null
+++ b/tests/user_commands/management/commands/mutually_exclusive_required.py
@@ -0,0 +1,12 @@
+from django.core.management.base ... | call_command fails when argument of required mutually exclusive group is passed in kwargs.
Description
This error
django.core.management.base.CommandError: Error: one of the arguments --shop-id --shop is required
is raised when I run
call_command('my_command', shop_id=1)
the argument 'shop_id' is part of a required... | Thanks for this report. I attached a simple test. Reproduced at ed2d411aa84efc76baba3adf0d0f99df0e44ba57. | 2019-09-05T21:47:44Z | 3.0 | ["test_mutually_exclusive_group_required_options (user_commands.tests.CommandTests)"] | ["test_get_random_secret_key (user_commands.tests.UtilsTests)", "test_is_ignored_path_false (user_commands.tests.UtilsTests)", "test_is_ignored_path_true (user_commands.tests.UtilsTests)", "test_no_existent_external_program (user_commands.tests.UtilsTests)", "test_normalize_path_patterns_truncates_wildcard_base (user_c... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11820 | c2678e49759e5c4c329bff0eeca2886267005d21 | 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
@@ -1708,9 +1708,15 @@ def _check_ordering(cls):
fld = None
for part in field.split(LOOKUP_SEP):
try:
- fld = _cls._meta.get_field(... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -814,6 +814,26 @@ class Meta:
)
])
+ def test_ordering_pointing_multiple_times_to_model_fields(... | models.E015 is raised when Meta.ordering contains "pk" of a related field.
Description
models.E015 is raised when Meta.ordering contains __pk of a related field, e.g.:
test_app.SomeModel: (models.E015) 'ordering' refers to the nonexistent field, related field, or lookup 'option__pk'.
Regression in 440505cb2cadbe1a5b9... | Regression test.
Thanks @felixxm for the test. I will prepare a fix for it. | 2019-09-26T08:37:14Z | 3.1 | ["test_ordering_pointing_multiple_times_to_model_fields (invalid_models_tests.test_models.OtherModelTests)", "test_ordering_pointing_to_related_model_pk (invalid_models_tests.test_models.OtherModelTests)"] | ["test_check_constraints (invalid_models_tests.test_models.ConstraintsTests)", "test_check_constraints_required_db_features (invalid_models_tests.test_models.ConstraintsTests)", "test_db_column_clash (invalid_models_tests.test_models.FieldNamesTests)", "test_ending_with_underscore (invalid_models_tests.test_models.Fiel... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-11880 | 06909fe084f87a65459a83bd69d7cdbe4fce9a7c | diff --git a/django/forms/fields.py b/django/forms/fields.py
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -199,6 +199,7 @@ def __deepcopy__(self, memo):
result = copy.copy(self)
memo[id(self)] = result
result.widget = copy.deepcopy(self.widget, memo)
+ result.error_mess... | diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -3685,6 +3685,17 @@ def test_empty_data_files_multi_value_dict(self):
self.assertIsInstance(p.data, MultiValueDict)
self... | Form Field’s __deepcopy__ does not (deep)copy the error messages.
Description
The __deepcopy__ method defined for the formfields (https://github.com/django/django/blob/146086f219d01dbb1cd8c089b5a5667e396e1cc4/django/forms/fields.py#L200) performs a shallow copy of self and does not include additional treatment for t... | Thanks for this report. I attached a simple test. Reproduced at f52022ad96356d4b1061610f2b74ea4d1956a608.
Simple test.
PR | 2019-10-07T19:10:59Z | 3.1 | ["test_field_deep_copy_error_messages (forms_tests.tests.test_forms.FormsTestCase)"] | ["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-11885 | 04ac9b45a34440fa447feb6ae934687aacbfc5f4 | 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
@@ -182,9 +182,9 @@ def collect(self, objs, source=None, source_attr=None, **kwargs):
except models.ProtectedError as e:
self.protected.update(e.protec... | diff --git a/tests/delete/tests.py b/tests/delete/tests.py
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -582,3 +582,11 @@ def test_fast_delete_empty_no_update_can_self_select(self):
User.objects.filter(avatar__desc='missing').delete(),
(0, {'delete.User': 0})
... | Combine fast delete queries
Description
When emulating ON DELETE CASCADE via on_delete=models.CASCADE the deletion.Collector will try to perform fast queries which are DELETE FROM table WHERE table.pk IN .... There's a few conditions required for this fast path to be taken but when this happens the collection logic s... | 2019-10-08T15:22:07Z | 3.1 | ["test_fast_delete_combined_relationships (delete.tests.FastDeleteTests)"] | ["test_fast_delete_empty_no_update_can_self_select (delete.tests.FastDeleteTests)", "test_fast_delete_fk (delete.tests.FastDeleteTests)", "test_fast_delete_inheritance (delete.tests.FastDeleteTests)", "test_fast_delete_instance_set_pk_none (delete.tests.FastDeleteTests)", "test_fast_delete_joined_qs (delete.tests.FastD... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 1-4 hours | |
django/django | django__django-12039 | 58c1acb1d6054dfec29d0f30b1033bae6ef62aec | 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
@@ -83,10 +83,14 @@ def __init__(self, table, columns, quote_name, col_suffixes=()):
def __str__(self):
def col_str(column, idx):... | diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -75,6 +75,22 @@ def test_index_together_single_list(self):
index_sql = connection.schema_editor()._model_indexes_sql(IndexTogetherSingleList)
self.assertEqual(len(index_sql), 1)
... | Use proper whitespace in CREATE INDEX statements
Description
(last modified by Hannes Ljungberg)
Creating an index through:
index = Index(
fields=['-name’],
name='idx'
)
Will generate the valid but not so pretty CREATE INDEX statement:
CREATE INDEX "idx" ON "schema_author" ("name"DESC)
The following would be... | PR: https://github.com/django/django/pull/12039
OK, I'll Accept this as a clean up (there's not actually an error right?). The patch looks small/clean enough at first glance.
Correct, no error. But since it's not documented as valid syntax to not have whitespace between the column and the ordering it could break in fu... | 2019-11-06T21:14:34Z | 3.1 | ["test_descending_columns_list_sql (indexes.tests.SchemaIndexesTests)"] | ["test_columns_list_sql (indexes.tests.SchemaIndexesTests)", "test_index_name (indexes.tests.SchemaIndexesTests)", "test_index_name_hash (indexes.tests.SchemaIndexesTests)", "test_index_together (indexes.tests.SchemaIndexesTests)", "test_index_together_single_list (indexes.tests.SchemaIndexesTests)", "test_create_index... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12050 | b93a0e34d9b9b99d41103782b7e7aeabf47517e3 | 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
@@ -1059,21 +1059,10 @@ def resolve_lookup_value(self, value, can_reuse, allow_joins, simple_col):
elif isinstance(value, (list, tuple)):
# The items o... | diff --git a/tests/queries/test_query.py b/tests/queries/test_query.py
--- a/tests/queries/test_query.py
+++ b/tests/queries/test_query.py
@@ -113,3 +113,10 @@ def test_clone_select_related(self):
clone = query.clone()
clone.add_select_related(['note', 'creator__extra'])
self.assertEqual(quer... | Query.resolve_lookup_value coerces value of type list to tuple
Description
Changes introduced in #30687 cause an input value list to be coerced to tuple breaking exact value queries. This affects ORM field types that are dependent on matching input types such as PickledField.
The expected iterable return type should ... | 2019-11-10T08:53:45Z | 3.1 | ["test_iterable_lookup_value (queries.test_query.TestQuery)"] | ["test_clone_select_related (queries.test_query.TestQuery)", "test_complex_query (queries.test_query.TestQuery)", "test_foreign_key (queries.test_query.TestQuery)", "test_foreign_key_exclusive (queries.test_query.TestQuery)", "test_foreign_key_f (queries.test_query.TestQuery)", "test_multiple_fields (queries.test_query... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12155 | e8fcdaad5c428878d0a5d6ba820d957013f75595 | 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
@@ -3,6 +3,7 @@
import re
from email.errors import HeaderParseError
from email.parser import HeaderParser
+from inspect import cleandoc
from django.url... | diff --git a/tests/admin_docs/test_utils.py b/tests/admin_docs/test_utils.py
--- a/tests/admin_docs/test_utils.py
+++ b/tests/admin_docs/test_utils.py
@@ -1,8 +1,9 @@
import unittest
from django.contrib.admindocs.utils import (
- docutils_is_available, parse_docstring, parse_rst, trim_docstring,
+ docutils_is... | docutils reports an error rendering view docstring when the first line is not empty
Description
Currently admindoc works correctly only with docstrings where the first line is empty, and all Django docstrings are formatted in this way.
However usually the docstring text starts at the first line, e.g.:
def test():
""... | Confirmed the patch fixes the issue, although it crashes for some tests with ValueError: min() arg is an empty sequence.
We should probably just switch to inspect.cleandoc as it implements the algorithm defined in PEP257.
Replying to Tim Graham: Confirmed the patch fixes the issue, although it crashes for some tests ... | 2019-11-28T16:24:23Z | 3.1 | ["test_parse_rst_with_docstring_no_leading_line_feed (admin_docs.test_utils.TestUtils)"] | ["test_description_output (admin_docs.test_utils.TestUtils)", "test_initial_header_level (admin_docs.test_utils.TestUtils)", "test_parse_docstring (admin_docs.test_utils.TestUtils)", "test_parse_rst (admin_docs.test_utils.TestUtils)", "test_publish_parts (admin_docs.test_utils.TestUtils)", "test_title_output (admin_doc... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12193 | 3fb7c12158a2402f0f80824f6778112071235803 | diff --git a/django/forms/widgets.py b/django/forms/widgets.py
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -522,9 +522,7 @@ def format_value(self, value):
def get_context(self, name, value, attrs):
if self.check_test(value):
- if attrs is None:
- attrs = {}
-... | diff --git a/tests/forms_tests/widget_tests/test_checkboxinput.py b/tests/forms_tests/widget_tests/test_checkboxinput.py
--- a/tests/forms_tests/widget_tests/test_checkboxinput.py
+++ b/tests/forms_tests/widget_tests/test_checkboxinput.py
@@ -89,3 +89,8 @@ def test_value_from_datadict_string_int(self):
def test_va... | SplitArrayField with BooleanField always has widgets checked after the first True value.
Description
(last modified by Peter Andersen)
When providing a SplitArrayField BooleanField with preexisting data, the final_attrs dict is updated to include 'checked': True after the for loop has reached the first True val... | Changes available here: https://github.com/django/django/pull/12193
Thanks for the report. Reproduced at 5708327c3769262b845730996ca2784245ada4d1. | 2019-12-08T01:38:25Z | 3.1 | ["test_get_context_does_not_mutate_attrs (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)"] | ["test_render_check_exception (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)", "test_render_check_test (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)", "test_render_empty (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)", "test_render_false (forms_tests.widget_tests.test... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12209 | 5a68f024987e6d16c2626a31bf653a2edddea579 | 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
@@ -849,6 +849,7 @@ def _save_table(self, raw=False, cls=None, force_insert=False,
updated = False
# Skip an UPDATE when adding an instance and primary key has a default.
... | diff --git a/tests/serializers/models/data.py b/tests/serializers/models/data.py
--- a/tests/serializers/models/data.py
+++ b/tests/serializers/models/data.py
@@ -4,6 +4,8 @@
NULL values, where allowed.
The basic idea is to have a model for each Django data type.
"""
+import uuid
+
from django.contrib.contenttypes.... | Change in behaviour when saving a model instance with an explcit pk value if the pk field has a default
Description
(last modified by Reupen Shah)
Consider the following model:
from uuid import uuid4
from django.db import models
class Sample(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4)... | It looks like the logic in _save_table should not force an insert if an explicit pk value is provided. The logic should likely take pk_set into account if ( not pk_set and self._state.adding and self._meta.pk.default and self._meta.pk.default is not NOT_PROVIDED ): force_insert = True I'm surprised this was not caught... | 2019-12-12T04:11:05Z | 3.1 | ["partial(func, *args, **keywords) - new function with partial application"] | [] | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12262 | 69331bb851c34f05bc77e9fc24020fe6908b9cd5 | diff --git a/django/template/library.py b/django/template/library.py
--- a/django/template/library.py
+++ b/django/template/library.py
@@ -261,7 +261,7 @@ def parse_bits(parser, bits, params, varargs, varkw, defaults,
if kwarg:
# The kwarg was successfully extracted
param, value = kwa... | diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py
--- a/tests/template_tests/templatetags/inclusion.py
+++ b/tests/template_tests/templatetags/inclusion.py
@@ -136,6 +136,15 @@ def inclusion_one_default(one, two='hi'):
inclusion_one_default.anything = "Expecte... | Custom template tags raise TemplateSyntaxError when keyword-only arguments with defaults are provided.
Description
(last modified by P-Seebauer)
When creating simple tags without variable keyword args, but an keyword argument with a default value. It's not possible to supply any other variable.
@register.simple... | 2019-12-30T13:13:59Z | 3.1 | ["test_inclusion_tag_errors (template_tests.test_custom.InclusionTagTests)", "test_inclusion_tags (template_tests.test_custom.InclusionTagTests)", "test_simple_tag_errors (template_tests.test_custom.SimpleTagTests)", "test_simple_tags (template_tests.test_custom.SimpleTagTests)"] | ["test_decorated_filter (template_tests.test_custom.CustomFilterTests)", "test_filter (template_tests.test_custom.CustomFilterTests)", "test_15070_use_l10n (template_tests.test_custom.InclusionTagTests)", "test_include_tag_missing_context (template_tests.test_custom.InclusionTagTests)", "test_inclusion_tag_registration... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12273 | 927c903f3cd25c817c21738328b53991c035b415 | 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
@@ -569,6 +569,9 @@ def _get_pk_val(self, meta=None):
return getattr(self, meta.pk.attname)
def _set_pk_val(self, value):
+ for parent_link in self._meta.parents.values()... | diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -10,10 +10,11 @@
from .models import (
ArticleWithAuthor, BachelorParty, BirthdayParty, BusStation, Child,
- Derive... | Resetting primary key for a child model doesn't work.
Description
In the attached example code setting the primary key to None does not work (so that the existing object is overwritten on save()).
The most important code fragments of the bug example:
from django.db import models
class Item(models.Model):
# uid = mod... | I'm not sure if this is a bug. The test passes after adding self.item_ptr = None to Item.reset(). Is that the behavior you're looking for?
I agree with Tim here. It feels like what you're after is self.pk = None as it will be alias for self.item_ptr for Derived instances and self.uid for Item instances.
@Simon Charette... | 2020-01-03T18:47:56Z | 3.1 | ["test_create_new_instance_with_pk_equals_none (model_inheritance_regress.tests.ModelInheritanceTest)", "test_create_new_instance_with_pk_equals_none_multi_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)"] | ["test_abstract_base_class_m2m_relation_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_abstract_verbose_name_plural_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_all_fields_from_abstract_base_class (model_inheritance_regress.tests.ModelInheritanceTest)", "test_co... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12304 | 4c1b401e8250f9f520b3c7dc369554477ce8b15a | diff --git a/django/db/models/enums.py b/django/db/models/enums.py
--- a/django/db/models/enums.py
+++ b/django/db/models/enums.py
@@ -31,6 +31,7 @@ def __new__(metacls, classname, bases, classdict):
# that is passed in as "self" as the value to use when looking up the
# label in the choices.
... | diff --git a/tests/model_enums/tests.py b/tests/model_enums/tests.py
--- a/tests/model_enums/tests.py
+++ b/tests/model_enums/tests.py
@@ -4,6 +4,7 @@
import uuid
from django.db import models
+from django.template import Context, Template
from django.test import SimpleTestCase
from django.utils.functional import ... | Enumeration Types are not usable in templates.
Description
(last modified by Mariusz Felisiak)
The new enumeration types are great but can't be used in Django templates due to their being callable. For example this doesn't work:
{% if student.year_in_school == YearInSchool.FRESHMAN %}
This is because YearInSch... | 2020-01-09T15:43:51Z | 3.1 | ["test_templates (model_enums.tests.ChoicesTests)"] | ["test_integerchoices (model_enums.tests.ChoicesTests)", "test_integerchoices_auto_label (model_enums.tests.ChoicesTests)", "test_integerchoices_containment (model_enums.tests.ChoicesTests)", "test_integerchoices_empty_label (model_enums.tests.ChoicesTests)", "test_integerchoices_functional_api (model_enums.tests.Choic... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix | |
django/django | django__django-12308 | 2e0f04507b17362239ba49830d26fec504d46978 | 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
@@ -398,6 +398,11 @@ def display_for_field(value, field, empty_value_display):
return formats.number_format(value)
elif isinstance(field, models.FileField) and... | 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
@@ -176,6 +176,23 @@ def test_null_display_for_field(self):
display_value = display_for_field(None, models.FloatField(), self.empty_value)
self.assertEqual(display_val... | JSONField are not properly displayed in admin when they are readonly.
Description
JSONField values are displayed as dict when readonly in the admin.
For example, {"foo": "bar"} would be displayed as {'foo': 'bar'}, which is not valid JSON.
I believe the fix would be to add a special case in django.contrib.admin.utils... | PR
The proposed patch is problematic as the first version coupled contrib.postgres with .admin and the current one is based off the type name which is brittle and doesn't account for inheritance. It might be worth waiting for #12990 to land before proceeding here as the patch will be able to simply rely of django.db.m... | 2020-01-12T04:21:15Z | 3.1 | ["test_json_display_for_field (admin_utils.tests.UtilsTests)", "test_label_for_field (admin_utils.tests.UtilsTests)"] | ["test_cyclic (admin_utils.tests.NestedObjectsTests)", "test_non_added_parent (admin_utils.tests.NestedObjectsTests)", "test_on_delete_do_nothing (admin_utils.tests.NestedObjectsTests)", "test_queries (admin_utils.tests.NestedObjectsTests)", "test_relation_on_abstract (admin_utils.tests.NestedObjectsTests)", "test_sibl... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12406 | 335c9c94acf263901fb023404408880245b0c4b4 | 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
@@ -980,6 +980,7 @@ def formfield(self, *, using=None, **kwargs):
'queryset': self.remote_field.model._default_manager.using(using),
... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -393,6 +393,9 @@ class Character(models.Model):
username = models.CharField(max_length=100)
last_action = models.DateTimeField()
+ def __str__(self):
+ retu... | ModelForm RadioSelect widget for foreign keys should not present a blank option if blank=False on the model
Description
Unlike the select widget, where a blank option is idiomatic even for required fields, radioselect has an inherent unfilled state that makes the "-------" option look suspiciously like a valid choice... | A pull request is available here: https://github.com/django/django/pull/11199
PR | 2020-02-02T16:34:05Z | 3.1 | ["test_non_blank_foreign_key_with_radio (model_forms.tests.ModelFormBaseTest)", "test_choices_radio_blank (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_clean_model_instance (model_forms.test_modelchoicefield.ModelChoiceFieldTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "test_notrequired_overrides_notblank (model_forms.tests.ValidationTest)", "test_validates_with_replaced_field_excluded (model_forms.tests.ValidationTest)", "test_validates_with_replaced_field_not_specified (model_forms.tests.ValidationTest... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12419 | 7fa1a93c6c8109010a6ff3f604fda83b604e0e97 | diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -637,6 +637,6 @@ def gettext_noop(s):
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_REDIRECT_EXEMPT = []
-SECURE_REFERRER_POLICY = None
+SECURE_REFERR... | diff --git a/tests/project_template/test_settings.py b/tests/project_template/test_settings.py
--- a/tests/project_template/test_settings.py
+++ b/tests/project_template/test_settings.py
@@ -38,6 +38,7 @@ def test_middleware_headers(self):
self.assertEqual(headers, [
b'Content-Length: 0',
... | Add secure default SECURE_REFERRER_POLICY / Referrer-policy header
Description
#29406 added the ability for the SECURE_REFERRER_POLICY setting to set Referrer-Policy, released in Django 3.0.
I propose we change the default for this to "same-origin" to make Django applications leak less information to third party site... | Hi Adam, Yes, I think this fits our secure by default philosophy. As long as the BC is documented in the release notes I think we should have this. | 2020-02-05T10:02:56Z | 3.1 | ["test_middleware_headers (project_template.test_settings.TestStartProjectSettings)"] | [] | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12708 | 447980e72ac01da1594dd3373a03ba40b7ee6f80 | 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
@@ -393,7 +393,12 @@ def alter_index_together(self, model, old_index_together, new_index_together):
news = {tuple(fields) for fields in new_index_to... | diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -62,7 +62,11 @@ def assertIndexExists(self, table, columns, value=True, using='default', index_t
any(
c["index"]
... | Migration crashes deleting an index_together if there is a unique_together on the same fields
Description
Happens with Django 1.11.10
Steps to reproduce:
1) Create models with 2 fields, add 2 same fields to unique_together and to index_together
2) Delete index_together -> Fail
It will fail at django/db/backends/base/... | Reproduced on master at 623139b5d1bd006eac78b375bcaf5948e695c3c6.
I haven't looked under the hood on this yet, but could it be related to the ordering of the operations generated for the mgiration? on first inspection it feels like this and #28862 could be caused by the same/similar underlying problem in how FieldRelat... | 2020-04-12T22:20:59Z | 3.1 | ["test_alter_index_together_remove_with_unique_together (migrations.test_operations.OperationTests)"] | ["test_references_model_mixin (migrations.test_operations.TestCreateModel)", "test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.Fiel... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 1-4 hours |
django/django | django__django-12741 | 537d422942b53bc0a2b6a51968f379c0de07793c | diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -60,7 +60,7 @@ def handle(self, **options):
if confirm == 'yes':
try:
- connection.ops.... | diff --git a/tests/backends/base/test_operations.py b/tests/backends/base/test_operations.py
--- a/tests/backends/base/test_operations.py
+++ b/tests/backends/base/test_operations.py
@@ -172,7 +172,7 @@ def test_execute_sql_flush_statements(self):
reset_sequences=True,
allow_cascade=True,
... | Simplify signature of `DatabaseOperations.execute_sql_flush()`
Description
The current signature is:
def execute_sql_flush(self, using, sql_list):
The using argument can be dropped and inferred by the calling instance: self.connection.alias.
def execute_sql_flush(self, sql_list):
Some internal ises of this method are... | 2020-04-17T22:35:55Z | 3.1 | ["test_execute_sql_flush_statements (backends.base.test_operations.SqlFlushTests)", "test_sequence_name_length_limits_flush (backends.tests.LongNameTest)"] | ["test_parameter_escaping (backends.tests.EscapingChecksDebug)", "test_paramless_no_escaping (backends.tests.EscapingChecksDebug)", "test_django_date_extract (backends.tests.DateQuotingTest)", "test_django_date_trunc (backends.tests.DateQuotingTest)", "test_parameter_escaping (backends.tests.EscapingChecks)", "test_par... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix | |
django/django | django__django-12754 | 18759b2209ff556aed7f20d83cbf23e3d234e41c | 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
@@ -563,6 +563,16 @@ def generate_created_models(self):
if isinstance(base, str) and "." in base:
base_app_... | 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
@@ -2454,3 +2454,28 @@ def test_mti_inheritance_model_removal(self):
self.assertNumberMigrations(changes, 'app', 1)
self.as... | FieldError when migrating field to new model subclass.
Description
Analogous to #21890. If creating a model subclass and moving a field onto it in the same step, makemigrations works but migrate dies with django.core.exceptions.FieldError: Local field 'title' in class 'Book' clashes with field of the same name from b... | Tentatively accepted for a future investigation. I'm not sure if this is feasible because detecting changes related with models' bases are tricky. Moreover you will lose data with such change, so IMO it's preferable to handle this manually.
Maybe the makemigrations could present some kind of info about the data being l... | 2020-04-19T10:59:30Z | 3.2 | ["test_add_model_with_field_removed_from_base_model (migrations.test_autodetector.AutodetectorTests)"] | ["test_add_alter_order_with_respect_to (migrations.test_autodetector.AutodetectorTests)", "test_add_blank_textfield_and_charfield (migrations.test_autodetector.AutodetectorTests)", "Test change detection of new constraints.", "test_add_date_fields_with_auto_now_add_asking_for_default (migrations.test_autodetector.Autod... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
django/django | django__django-12858 | f2051eb8a7febdaaa43bd33bf5a6108c5f428e59 | 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
@@ -1747,7 +1747,9 @@ def _check_ordering(cls):
else:
_cls = None
except (FieldDoesNotExist, AttributeError):
- ... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -893,6 +893,15 @@ class Meta:
with register_lookup(models.CharField, Lower):
self.assertEqual(Model.... | models.E015 is raised when ordering uses lookups that are not transforms.
Description
./manage.py check
SystemCheckError: System check identified some issues:
ERRORS:
app.Stock: (models.E015) 'ordering' refers to the nonexistent field, related field, or lookup 'supply__product__parent__isnull'.
However this ordering ... | 2020-05-05T04:49:02Z | 3.1 | ["test_ordering_pointing_to_lookup_not_transform (invalid_models_tests.test_models.OtherModelTests)"] | ["test_check_constraints (invalid_models_tests.test_models.ConstraintsTests)", "test_check_constraints_required_db_features (invalid_models_tests.test_models.ConstraintsTests)", "test_deferrable_unique_constraint (invalid_models_tests.test_models.ConstraintsTests)", "test_deferrable_unique_constraint_required_db_featur... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12965 | 437196da9a386bd4cc62b0ce3f2de4aba468613d | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1407,6 +1407,8 @@ def execute_sql(self, returning_fields=None):
class SQLDeleteCompiler(SQLCompiler):
@cached_property
def single_alias(self):
+ ... | diff --git a/tests/delete/tests.py b/tests/delete/tests.py
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -605,6 +605,12 @@ def receiver(instance, **kwargs):
class FastDeleteTests(TestCase):
+ def test_fast_delete_all(self):
+ with self.assertNumQueries(1) as ctx:
+ User.objects.al... | Model.objects.all().delete() subquery usage performance regression
Description
Lock tests are failing with Django-MySQL on Django 3.1: https://github.com/adamchainz/django-mysql/pull/660 .
The tests run Model.objects.all().delete().
Django 3.0 generates this SQL:
DELETE FROM `testapp_alphabet`
Django 3.1 generates t... | It looks like this was added in #23576 / PR #11931
It should be possible to prevent the query when dealing with a single alias. It looks like this is a regression on other backends as well. | 2020-05-24T13:20:03Z | 3.2 | ["test_fast_delete_all (delete.tests.FastDeleteTests)"] | ["test_fast_delete_combined_relationships (delete.tests.FastDeleteTests)", "test_fast_delete_empty_no_update_can_self_select (delete.tests.FastDeleteTests)", "test_fast_delete_fk (delete.tests.FastDeleteTests)", "test_fast_delete_inheritance (delete.tests.FastDeleteTests)", "test_fast_delete_instance_set_pk_none (delet... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
django/django | django__django-13023 | f83b44075dafa429d59e8755aa47e15577cc49f9 | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -1501,7 +1501,7 @@ def to_python(self, value):
return self.context.create_decimal_from_float(value)
try:
return... | diff --git a/tests/model_fields/test_decimalfield.py b/tests/model_fields/test_decimalfield.py
--- a/tests/model_fields/test_decimalfield.py
+++ b/tests/model_fields/test_decimalfield.py
@@ -21,9 +21,24 @@ def test_to_python(self):
# Uses default rounding of ROUND_HALF_EVEN.
self.assertEqual(f.to_pyth... | DecimalField.to_python() raises TypeError on dict values.
Description
A call to DecimalField.to_python() with a dictionary as the value parameter produces TypeError instead of ValidationError. This is a problem, for example, when you try to save a model object, and a decimal field got set to a dictionary by mistake. ... | 2020-06-04T20:40:44Z | 3.2 | ["test_invalid_value (model_fields.test_decimalfield.DecimalFieldTests)", "test_lookup_really_big_value (model_fields.test_decimalfield.DecimalFieldTests)"] | ["test_default (model_fields.test_decimalfield.DecimalFieldTests)", "test_filter_with_strings (model_fields.test_decimalfield.DecimalFieldTests)", "test_get_prep_value (model_fields.test_decimalfield.DecimalFieldTests)", "test_max_decimal_places_validation (model_fields.test_decimalfield.DecimalFieldTests)", "test_max_... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix | |
django/django | django__django-13089 | 27c09043da52ca1f02605bf28600bfd5ace95ae4 | diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -267,9 +267,12 @@ def _cull(self, db, cursor, now):
cursor.execute(
connection.ops.cache_key_culling_sql() % table,
... | diff --git a/tests/cache/tests.py b/tests/cache/tests.py
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -621,6 +621,20 @@ def test_cull(self):
def test_zero_cull(self):
self._perform_cull_test('zero_cull', 50, 19)
+ def test_cull_delete_when_store_empty(self):
+ try:
+ cul... | cache.backends.db._cull sometimes fails with 'NoneType' object is not subscriptable
Description
(last modified by Guillermo Bonvehí)
I'm sporadically getting some cache errors using database backend.
The error is: 'NoneType' object is not subscriptable
And the backtrace:
/usr/local/lib/python3.7/site-packages/d... | 2020-06-20T07:36:10Z | 3.2 | ["test_cull_delete_when_store_empty (cache.tests.DBCacheTests)", "test_cull_delete_when_store_empty (cache.tests.DBCacheWithTimeZoneTests)"] | ["If None is cached, get() returns it instead of the default.", "Nonexistent cache keys return as None/default.", "set_many() returns an empty list when all keys are inserted.", "test_custom_key_validation (cache.tests.CustomCacheKeyValidationTests)", "test_long_vary_on (cache.tests.TestMakeTemplateFragmentKey)", "test... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix | |
django/django | django__django-13109 | fbe82f82555bc25dccb476c749ca062f0b522be3 | 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
@@ -914,7 +914,7 @@ def validate(self, value, model_instance):
return
using = router.db_for_read(self.remote_field.model, instanc... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -28,8 +28,17 @@ def __repr__(self):
return self.__str__()
+class WriterManager(models.Manager):
+ def get_queryset(self):
+ qs = super().get_queryset()
+ ... | ForeignKey.validate() should validate using the base manager.
Description
ForeignKey.validate() should validate using the base manager instead of the default manager.
Consider the models:
class ArticleManager(models.Manage):
def get_queryset(self):
qs = super().get_queryset()
return qs.filter(archived=False)
cla... | https://github.com/django/django/pull/12923
OK, yes, let's provisionally Accept this: I think it's probably correct. (At this level we're avoiding DB errors, not business logic errors, like "was this archived", which properly belong to the form layer...)
I take it the change here is ORM rather than forms per se.
I tak... | 2020-06-25T08:36:45Z | 3.2 | ["test_FK_validates_using_base_manager (validation.tests.BaseModelValidationTests)", "test_validate_foreign_key_to_model_with_overridden_manager (model_forms.tests.ModelFormBasicTests)"] | ["test_model_form_clean_applies_to_model (model_forms.tests.CustomCleanTests)", "test_override_clean (model_forms.tests.CustomCleanTests)", "test_setattr_raises_validation_error_field_specific (model_forms.tests.StrictAssignmentTests)", "test_setattr_raises_validation_error_non_field (model_forms.tests.StrictAssignment... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix |
django/django | django__django-13158 | 7af8f4127397279d19ef7c7899e93018274e2f9b | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -305,6 +305,7 @@ def clone(self):
obj.annotation_select_mask = None
else:
obj.annotation_select_mask = self.annotation_select_mask.copy... | diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
--- a/tests/queries/test_qs_combinators.py
+++ b/tests/queries/test_qs_combinators.py
@@ -51,6 +51,13 @@ def test_union_distinct(self):
self.assertEqual(len(list(qs1.union(qs2, all=True))), 20)
self.assertEqual(le... | QuerySet.none() on combined queries returns all results.
Description
I came across this issue on Stack Overflow. I'm not 100% sure it's a bug, but it does seem strange. With this code (excuse the bizarre example filtering):
class Publication(models.Model):
pass
class Article(models.Model):
publications = models.Man... | Thanks for the report. QuerySet.none() doesn't work properly on combined querysets, it returns all results instead of an empty queryset. | 2020-07-06T19:18:11Z | 3.2 | ["test_union_none (queries.test_qs_combinators.QuerySetSetOperationTests)"] | ["test_combining_multiple_models (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_difference (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_intersection (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_union (queries.test_qs_combinators.QuerySetSetOperati... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
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)"] | ["test_get_context_data_super (generic_views.test_base.GetContextDataTest)", "test_object_at_custom_name_in_context_data (generic_views.test_base.GetContextDataTest)", "test_object_in_get_context_data (generic_views.test_base.GetContextDataTest)", "test_overwrite_queryset (generic_views.test_base.UseMultipleObjectMixin... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix |
django/django | django__django-13315 | 36bc47069ce071e80c8129500de3b8664d2058a7 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -97,10 +97,18 @@ def model_to_dict(instance, fields=None, exclude=None):
def apply_limit_choices_to_to_formfield(formfield):
"""Apply limit_choices_to to the formfield's queryset if needed."... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -411,9 +411,14 @@ class StumpJoke(models.Model):
Character,
models.CASCADE,
limit_choices_to=today_callable_dict,
- related_name="+",
+ r... | limit_choices_to on a ForeignKey can render duplicate options in formfield
Description
If you pass a Q object as limit_choices_to on a ForeignKey field involving a join, you may end up with duplicate options in your form.
See regressiontest in patch for a clear view on the problem.
| Replying to SmileyChris: I've updated the patch to resolve the conflicts I've had since you flagged this one as "Ready for checkin". No real change.
update resolving conflict
Is there something I can do to get this checked in? I re-read the Triage docs. As far as I can see "A developer checks in the fix" is the only s... | 2020-08-17T04:24:39Z | 3.2 | ["test_limit_choices_to_no_duplicates (model_forms.tests.LimitChoicesToTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "test_bad_callback (model_forms.tests.FormFieldCallbackTests)", "Regression for #13095: Using base forms with widgets defined in Meta should not raise errors.", "A custom formfield_callback is used if provided", "Regression for #15315: mod... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
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... | 2020-08-24T19:29:12Z | 3.2 | ["test_deconstruction (file_storage.tests.FieldCallableFileStorageTests)"] | ["test_get_filesystem_storage (file_storage.tests.GetStorageClassTests)", "test_get_invalid_storage_module (file_storage.tests.GetStorageClassTests)", "test_get_nonexistent_storage_class (file_storage.tests.GetStorageClassTests)", "test_get_nonexistent_storage_module (file_storage.tests.GetStorageClassTests)", "test_ca... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
django/django | django__django-13346 | 9c92924cd5d164701e2514e1c2d6574126bd7cc2 | diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py
--- a/django/db/models/fields/json.py
+++ b/django/db/models/fields/json.py
@@ -378,6 +378,30 @@ def as_sqlite(self, compiler, connection):
return super().as_sql(compiler, connection)
+class KeyTransformIn(lookups.In):
+ def ... | diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -627,6 +627,25 @@ def test_key_iexact(self):
self.assertIs(NullableJSONModel.objects.filter(value__foo__iexact='BaR').exists(), True)... | On MySQL, Oracle, and SQLite, __in lookup doesn't work on key transforms.
Description
I am currently rewriting our app where we will start using models.JSONField instead of django_mysql.models.JSONField. I noticed that the __in operator is not reacting the same way is it does on other fields.
first_filter = {‘our_fie... | Thanks for this ticket, however I cannot reproduce this issue. I tried with the following test and it works for me (also on MySQL): diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index a7648711ac..97d79e5bee 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fi... | 2020-08-25T06:25:31Z | 3.2 | ["test_key_in (model_fields.test_jsonfield.TestQuerying)", "test_key_iregex (model_fields.test_jsonfield.TestQuerying)"] | ["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_custom_encoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_decoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_encoder (model_fields... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
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_duration_unsupported_lookups (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_without_native_duration_field (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extra... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix |
django/django | django__django-13401 | 453967477e3ddae704cd739eac2449c0e13d464c | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -516,17 +516,37 @@ def clone(self):
def __eq__(self, other):
# Needed for @total_ordering
if isinstance(other, Field):
- ... | diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -102,6 +102,36 @@ def test_deconstruct_nested_field(self):
name, path, args, kwargs = Nested.Field().deconstruct()
self.assertEqual(path, 'model_fields.tests.Ne... | Abstract model field should not be equal across models
Description
Consider the following models:
class A(models.Model):
class Meta:
abstract = True
myfield = IntegerField()
class B(A):
pass
class C(A):
pass
If I pull the fields of B and C into a shared set, one will be de-duplicated away, because they compare ... | 2020-09-09T11:19:00Z | 3.2 | ["Field instances from abstract models are not equal."] | ["test_blank_in_choices (model_fields.tests.GetChoicesTests)", "test_blank_in_grouped_choices (model_fields.tests.GetChoicesTests)", "test_empty_choices (model_fields.tests.GetChoicesTests)", "test_lazy_strings_not_evaluated (model_fields.tests.GetChoicesTests)", "test_get_choices (model_fields.tests.GetChoicesLimitCho... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
django/django | django__django-13417 | 71ae1ab0123582cc5bfe0f7d5f4cc19a9412f396 | diff --git a/django/db/models/query.py b/django/db/models/query.py
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1224,7 +1224,12 @@ def ordered(self):
return True
if self.query.extra_order_by or self.query.order_by:
return True
- elif self.query.default_or... | diff --git a/tests/queries/tests.py b/tests/queries/tests.py
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2084,6 +2084,16 @@ def test_annotated_ordering(self):
self.assertIs(qs.ordered, False)
self.assertIs(qs.order_by('num_notes').ordered, True)
+ def test_annotated_default_orde... | QuerySet.ordered property is incorrect for GROUP BY queries on models with Meta.ordering.
Description
Using the annotate function on a queryset doesn't keep the default ordering set in model's meta class.
A property should say whether the queryset will be ordered or not. I wanted to use the qs.ordered property for th... | Thanks for this report, however QuerySet.ordered works for me, see tests.
Replying to felixxm: Thanks for this report, however QuerySet.ordered works for me, see tests. Thanks for your answer but I've just checked again as it is in my example and ordered still returns True if an annotation is applied. As said earlier... | 2020-09-14T07:49:15Z | 3.2 | ["test_annotated_default_ordering (queries.tests.QuerysetOrderedTests)", "test_annotated_values_default_ordering (queries.tests.QuerysetOrderedTests)"] | ["test_no_extra_params (queries.tests.DefaultValuesInsertTest)", "test_ticket14729 (queries.tests.RawQueriesTests)", "test_exists (queries.tests.ExistsSql)", "test_ticket_18414 (queries.tests.ExistsSql)", "test_ticket_24278 (queries.tests.TestTicket24279)", "test_ticket7371 (queries.tests.CustomPkTests)", "test_ticket_... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix |
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)"] | ["test_conditional_annotation (expressions_window.tests.NonQueryWindowTests)", "test_empty_group_by_cols (expressions_window.tests.NonQueryWindowTests)", "test_frame_empty_group_by_cols (expressions_window.tests.NonQueryWindowTests)", "test_frame_window_frame_notimplemented (expressions_window.tests.NonQueryWindowTests... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 1-4 hours |
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... | 2020-10-08T19:00:01Z | 3.2 | ["test_outputwrapper_flush (user_commands.tests.CommandTests)"] | ["test_requires_system_checks_false (user_commands.tests.DeprecationTests)", "test_requires_system_checks_true (user_commands.tests.DeprecationTests)", "test_requires_system_checks_warning (user_commands.tests.DeprecationTests)", "test_get_random_secret_key (user_commands.tests.UtilsTests)", "test_is_ignored_path_false... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
django/django | django__django-13568 | ede9fac75807fe5810df66280a60e7068cc97e4a | diff --git a/django/contrib/auth/checks.py b/django/contrib/auth/checks.py
--- a/django/contrib/auth/checks.py
+++ b/django/contrib/auth/checks.py
@@ -52,7 +52,10 @@ def check_user_model(app_configs=None, **kwargs):
)
# Check that the username field is unique
- if not cls._meta.get_field(cls.USERNAME... | diff --git a/tests/auth_tests/test_checks.py b/tests/auth_tests/test_checks.py
--- a/tests/auth_tests/test_checks.py
+++ b/tests/auth_tests/test_checks.py
@@ -4,6 +4,7 @@
from django.contrib.auth.models import AbstractBaseUser
from django.core import checks
from django.db import models
+from django.db.models import ... | Skip auth.E003 system check for USERNAME_FIELD with total UniqueConstraints.
Description
Defining a user model like this:
class User(AbstractBaseUser):
username = models.CharField(max_length=30)
USERNAME_FIELD = "username"
class Meta:
constraints = [UniqueConstraint(fields=["username"], name="user_username_unq")... | 2020-10-19T15:20:08Z | 3.2 | ["test_username_unique_with_model_constraint (auth_tests.test_checks.UserModelChecksTests)"] | ["test_clashing_custom_permissions (auth_tests.test_checks.ModelsPermissionsChecksTests)", "test_clashing_default_permissions (auth_tests.test_checks.ModelsPermissionsChecksTests)", "test_custom_permission_codename_max_length (auth_tests.test_checks.ModelsPermissionsChecksTests)", "test_custom_permission_name_max_lengt... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
django/django | django__django-13590 | 755dbf39fcdc491fe9b588358303e259c7750be4 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1077,10 +1077,14 @@ def resolve_lookup_value(self, value, can_reuse, allow_joins):
elif isinstance(value, (list, tuple)):
# The items of the iterab... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -2,6 +2,7 @@
import pickle
import unittest
import uuid
+from collections import namedtuple
from copy import deepcopy
from decimal import Decimal
from unittest import mock
@@ -8... | Upgrading 2.2>3.0 causes named tuples used as arguments to __range to error.
Description
I noticed this while upgrading a project from 2.2 to 3.0.
This project passes named 2-tuples as arguments to range queryset filters. This works fine on 2.2. On 3.0 it causes the following error: TypeError: __new__() missing 1 req... | 2020-10-23T09:34:55Z | 3.2 | ["test_range_lookup_namedtuple (expressions.tests.IterableLookupInnerExpressionsTests)"] | ["test_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_non_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_e... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
django/django | django__django-13670 | c448e614c60cc97c6194c62052363f4f501e0953 | diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -325,8 +325,8 @@ def W(self):
return self.data.isocalendar()[1]
def y(self):
- "Year, 2 digits; e.g. '99'"
- return str(self.data.year)[2:]
+ """... | diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py
--- a/tests/utils_tests/test_dateformat.py
+++ b/tests/utils_tests/test_dateformat.py
@@ -165,3 +165,16 @@ def test_r_format_with_non_en_locale(self):
dateformat.format(dt, 'r'),
'Sun, 08 Jul 1979 ... | dateformat.y() doesn't support years < 1000.
Description
(last modified by Sam)
When using the the dateformat of django with a date before 999 (or 99 and 9 for similar matters) and the format character "y" no leading zero will be printed. This is not consistent with the way the python datetime module and PHP ha... | 2020-11-12T11:45:51Z | 3.2 | ["test_year_before_1000 (utils_tests.test_dateformat.DateFormatTests)"] | ["test_am_pm (utils_tests.test_dateformat.DateFormatTests)", "test_date (utils_tests.test_dateformat.DateFormatTests)", "test_date_formats (utils_tests.test_dateformat.DateFormatTests)", "test_dateformat (utils_tests.test_dateformat.DateFormatTests)", "test_datetime_with_local_tzinfo (utils_tests.test_dateformat.DateFo... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
django/django | django__django-13809 | bef6f7584280f1cc80e5e2d80b7ad073a93d26ec | diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
--- a/django/core/management/commands/runserver.py
+++ b/django/core/management/commands/runserver.py
@@ -51,6 +51,10 @@ def add_arguments(self, parser):
'--noreload', action='store_false', dest='use_re... | diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1313,6 +1313,29 @@ def test_readonly_database(self):
# You have # ...
self.assertIn('unapplied migration(s)', self.output.getvalue())
+ @mock.patch('d... | Add --skip-checks option to the runserver command.
Description
Rationale:
It would be consistent with other management commands performing system checks
It would help people like me who would rather have checks enabled exclusively in CI/CD than wait 15-20 seconds for each project reload during development
Related Sta... | Sounds reasonable.
PR | 2020-12-24T15:31:35Z | 4.0 | ["test_skip_checks (admin_scripts.tests.ManageRunserver)"] | ["test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_ex... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour |
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... | 2020-12-28T22:07:57Z | 3.2 | ["test_loading_package_without__file__ (migrations.test_loader.LoaderTests)"] | ["test_apply (migrations.test_loader.RecorderTests)", "test_invalid (migrations.test_loader.PycLoaderTests)", "test_valid (migrations.test_loader.PycLoaderTests)", "test_check_consistent_history (migrations.test_loader.LoaderTests)", "test_check_consistent_history_squashed (migrations.test_loader.LoaderTests)", "test_e... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour | |
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... | 2021-01-04T17:44:23Z | 3.2 | ["test_run_as_non_django_module (utils_tests.test_autoreload.TestChildArguments)"] | ["test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception_with_context (utils_tests.test_autoreload.TestRaiseLastExce... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 1-4 hours | |
django/django | django__django-13964 | f39634ff229887bf7790c069d0c411b38494ca38 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -933,7 +933,7 @@ def _prepare_related_fields_for_save(self, operation_name):
"%s() prohibited to prevent data loss due to unsaved "
"related... | diff --git a/tests/many_to_one/models.py b/tests/many_to_one/models.py
--- a/tests/many_to_one/models.py
+++ b/tests/many_to_one/models.py
@@ -68,6 +68,10 @@ class Parent(models.Model):
bestchild = models.ForeignKey('Child', models.SET_NULL, null=True, related_name='favored_by')
+class ParentStringPrimaryKey(m... | Saving parent object after setting on child leads to data loss for parents with non-numeric primary key.
Description
(last modified by Charlie DeTar)
Given a model with a foreign key relation to another model that has a non-auto CharField as its primary key:
class Product(models.Model):
sku = models.CharField(... | Thanks for this report. product_id is an empty string in _prepare_related_fields_for_save() that's why pk from a related object is not used. We could use empty_values: diff --git a/django/db/models/base.py b/django/db/models/base.py index 822aad080d..8e7a8e3ae7 100644 --- a/django/db/models/base.py +++ b/django/db/mod... | 2021-02-02T17:07:43Z | 4.0 | ["test_save_fk_after_parent_with_non_numeric_pk_set_on_child (many_to_one.tests.ManyToOneTests)"] | ["test_add (many_to_one.tests.ManyToOneTests)", "test_add_after_prefetch (many_to_one.tests.ManyToOneTests)", "test_add_remove_set_by_pk_raises (many_to_one.tests.ManyToOneTests)", "test_add_then_remove_after_prefetch (many_to_one.tests.ManyToOneTests)", "test_assign (many_to_one.tests.ManyToOneTests)", "test_assign_fk... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour |
django/django | django__django-14007 | 619f26d2895d121854b1bed1b535d42b722e2eba | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1405,6 +1405,7 @@ def execute_sql(self, returning_fields=None):
returning_fields and len(self.query.objs) != 1 and
not self.connect... | diff --git a/tests/custom_pk/fields.py b/tests/custom_pk/fields.py
--- a/tests/custom_pk/fields.py
+++ b/tests/custom_pk/fields.py
@@ -20,7 +20,7 @@ def __eq__(self, other):
return self.value == other
-class MyAutoField(models.CharField):
+class MyWrapperField(models.CharField):
def __init__(self, *... | Database converters (from_db_value) not called for returning_fields on insert
Description
Making a subclass of BigAutoField, I've found that, unlike all other query pathways, on insert the returned integer is not passed through any database converters defined for the field - including the from_db_value hook.
This mea... | 2021-02-13T09:00:02Z | 4.0 | ["test_auto_field_subclass_create (custom_pk.tests.CustomPKTests)"] | ["Get can accept pk or the real attribute name", "Custom pks work with in_bulk, both for integer and non-integer types", "pk and attribute name are available on the model", "Both pk and custom attribute_name can be used in filter and friends", "Custom pk doesn't affect related_name based lookups", "Queries across table... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 1-4 hours | |
django/django | django__django-14011 | e4430f22c8e3d29ce5d9d0263fba57121938d06d | diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -16,6 +16,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import LimitedStream
from django.core.wsgi import get_wsg... | diff --git a/django/test/testcases.py b/django/test/testcases.py
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1513,11 +1513,12 @@ def run(self):
finally:
connections.close_all()
- def _create_server(self):
+ def _create_server(self, connections_override=None):
... | LiveServerTestCase's ThreadedWSGIServer doesn't close database connections after each thread
Description
In Django 2.2.17, I'm seeing the reappearance of #22414 after it was fixed in 1.11. #22414 is the issue where the following error will occur at the conclusion of a test run when destroy_test_db() is called:
Operat... | I wonder if this issue is because ThreadingMixIn creates a new thread for each request, but those threads don't close their database connections at their conclusion, e.g. like LiveServerThread does. Here is the code in CPython for ThreadingMixIn's process_request() and server_close(): https://github.com/python/cpython... | 2021-02-15T06:15:21Z | 4.0 | ["test_live_server_url_is_class_property (servers.tests.LiveServerAddress)", "Data written to the database by a view can be read.", "Fixtures are properly loaded and visible to the live server thread.", "test_check_model_instance_from_subview (servers.tests.LiveServerThreadedTests)", "test_view_calls_subview (servers.t... | ["test_set_up_class (servers.tests.LiveServerTestCaseSetupTest)", "Contrast to"] | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 1-4 hours |
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.0 | ["test_boolean_expression_combined (expressions.tests.BasicExpressionsTests)", "test_boolean_expression_combined_with_empty_Q (expressions.tests.BasicExpressionsTests)"] | ["test_resolve_output_field (expressions.tests.CombinedExpressionTests)", "test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_equal_Value (expressions.tests.FTests)", "test_and (expressions.... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour |
django/django | django__django-14238 | 30e123ed351317b7527f632b3b7dc4e81e850449 | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -2524,7 +2524,7 @@ def __instancecheck__(self, instance):
return isinstance(instance, self._subclasses) or super().__instancecheck__(inst... | diff --git a/tests/model_fields/test_autofield.py b/tests/model_fields/test_autofield.py
--- a/tests/model_fields/test_autofield.py
+++ b/tests/model_fields/test_autofield.py
@@ -30,6 +30,18 @@ def test_isinstance_of_autofield(self):
self.assertIsInstance(field(), models.AutoField)
def test_issu... | DEFAULT_AUTO_FIELD subclass check fails for subclasses of BigAutoField and SmallAutoField.
Description
Set DEFAULT_AUTO_FIELD = "example.core.models.MyBigAutoField" , with contents of example.core.models:
from django.db import models
class MyBigAutoField(models.BigAutoField):
pass
class MyModel(models.Model):
pass
... | 2021-04-08T10:41:31Z | 4.0 | ["test_issubclass_of_autofield (model_fields.test_autofield.AutoFieldInheritanceTests)", "test_default_auto_field_setting_bigautofield_subclass (model_options.test_default_pk.TestDefaultPK)"] | ["test_isinstance_of_autofield (model_fields.test_autofield.AutoFieldInheritanceTests)", "Backend specific ranges can be saved without corruption.", "Backend specific ranges are enforced at the model validation level", "test_coercing (model_fields.test_autofield.AutoFieldTests)", "Values within the documented safe rang... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour | |
django/django | django__django-14315 | 187118203197801c6cb72dc8b06b714b23b6dd3d | diff --git a/django/db/backends/base/client.py b/django/db/backends/base/client.py
--- a/django/db/backends/base/client.py
+++ b/django/db/backends/base/client.py
@@ -21,6 +21,5 @@ def settings_to_cmd_args_env(cls, settings_dict, parameters):
def runshell(self, parameters):
args, env = self.settings_to_... | diff --git a/tests/backends/base/test_client.py b/tests/backends/base/test_client.py
--- a/tests/backends/base/test_client.py
+++ b/tests/backends/base/test_client.py
@@ -1,3 +1,5 @@
+from unittest import mock
+
from django.db import connection
from django.db.backends.base.client import BaseDatabaseClient
from djang... | database client runshell doesn't respect os.environ values in some cases
Description
(last modified by Konstantin Alekseev)
postgresql client returns empty dict instead of None for env
as a result os.environ is not used and empty env passed
to subprocess.
Bug introduced in https://github.com/django/django/comm... | 2021-04-26T12:39:01Z | 4.0 | ["test_runshell_use_environ (backends.base.test_client.SimpleDatabaseClientTests)", "test_settings_to_cmd_args_env (backends.base.test_client.SimpleDatabaseClientTests)", "test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "t... | [] | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | <15 min fix | |
django/django | django__django-14373 | b1a4b1f0bdf05adbd3dc4dde14228e68da54c1a3 | diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -313,8 +313,8 @@ def y(self):
return '%02d' % (self.data.year % 100)
def Y(self):
- "Year, 4 digits; e.g. '1999'"
- return self.data.year
+ """Ye... | diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py
--- a/tests/utils_tests/test_dateformat.py
+++ b/tests/utils_tests/test_dateformat.py
@@ -166,7 +166,7 @@ def test_r_format_with_non_en_locale(self):
'Sun, 08 Jul 1979 22:00:00 +0100',
)
- def tes... | DateFormat.Y() is not zero-padded.
Description
The Y specifier for django.utils.dateformat.DateFormat is supposed to always return a four-digit year padded with zeros. This doesn't seem to be the case for year < 1000.
| 2021-05-10T14:40:32Z | 4.0 | ["test_Y_format_year_before_1000 (utils_tests.test_dateformat.DateFormatTests)"] | ["test_am_pm (utils_tests.test_dateformat.DateFormatTests)", "test_date (utils_tests.test_dateformat.DateFormatTests)", "test_date_formats (utils_tests.test_dateformat.DateFormatTests)", "test_dateformat (utils_tests.test_dateformat.DateFormatTests)", "test_datetime_with_local_tzinfo (utils_tests.test_dateformat.DateFo... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | <15 min fix | |
django/django | django__django-14376 | d06c5b358149c02a62da8a5469264d05f29ac659 | diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -200,9 +200,9 @@ def get_connection_params(self):
if settings_dict['USER']:
kwargs['user'] = settings_dict['USER']
if settings_... | diff --git a/tests/dbshell/test_mysql.py b/tests/dbshell/test_mysql.py
--- a/tests/dbshell/test_mysql.py
+++ b/tests/dbshell/test_mysql.py
@@ -50,41 +50,49 @@ def test_options_override_settings_proper_values(self):
'optiondbname',
]
expected_env = {'MYSQL_PWD': 'optionpassword'}
- ... | MySQL backend uses deprecated "db" and "passwd" kwargs.
Description
The "db" and "passwd" usage can be seen at https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/db/backends/mysql/base.py#L202-L205 in main. mysqlclient recently marked these two kwargs as deprecated (see https://gi... | Thanks for this report. Django 2.2, 3.1, and 3.2 all require a minimum version of mysqlclient newer than 1.3.8, so a fix for this could be backported to all currently supported versions of Django. Django 2.2 and 3.1 are in extended support so they don't receive bugfixes anymore (except security patches). We'll document... | 2021-05-10T20:42:18Z | 4.0 | ["test_options_non_deprecated_keys_preferred (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_options_override_settings_proper_values (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_parameters (dbshell.test_mysql.MySqlDbshellCommandTestCase)"] | ["test_basic_params_specified_in_settings (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_can_connect_using_sockets (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_crash_password_does_not_leak (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_fails_with_keyerror_on_incomplete_config (dbshell.te... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | <15 min fix |
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.
| 2021-05-23T12:27:14Z | 4.0 | ["test_unique_constraint (schema.tests.SchemaTests)"] | ["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour | |
django/django | django__django-14500 | 8c3bd0b708b488a1f6e8bd8cc6b96569904605be | diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -250,12 +250,11 @@ def unapply_migration(self, state, migration, fake=False):
if not fake:
with self.connection.schema_editor(atomic=mig... | diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py
--- a/tests/migrations/test_executor.py
+++ b/tests/migrations/test_executor.py
@@ -653,6 +653,23 @@ def test_migrate_marks_replacement_applied_even_if_it_did_nothing(self):
recorder.applied_migrations(),
)
+ @... | Squashed migration is not marked as unapplied
Description
(last modified by Markus Holtermann)
When unapplying a squashed migration and the replaced migration files are still around, the MigrationExecutor mark the squash migration as unapplied, too, not only the replaced migrations.
| While working on #24800 I realized that the issue is actually not fully correct. The squashed migration is not marked as applied.
PR: https://github.com/django/django/pull/5280
The commit this depends on is moved to "Work in progress" status, so moving this off the checkin queue.
Updated ticket, since original PR was ... | 2021-06-08T05:08:08Z | 4.0 | ["test_migrate_marks_replacement_unapplied (migrations.test_executor.ExecutorTests)"] | ["If the current state satisfies the given target, do nothing.", "Minimize unnecessary rollbacks in connected apps.", "Minimize rollbacks when target has multiple in-app children.", "test_alter_id_type_with_fk (migrations.test_executor.ExecutorTests)", "Applying all replaced migrations marks replacement as applied (#24... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour |
django/django | django__django-14559 | d79be3ed39b76d3e34431873eec16f6dd354ab17 | diff --git a/django/db/models/query.py b/django/db/models/query.py
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -541,7 +541,7 @@ def bulk_update(self, objs, fields, batch_size=None):
if any(f.primary_key for f in fields):
raise ValueError('bulk_update() cannot be used with pr... | diff --git a/tests/queries/test_bulk_update.py b/tests/queries/test_bulk_update.py
--- a/tests/queries/test_bulk_update.py
+++ b/tests/queries/test_bulk_update.py
@@ -125,7 +125,8 @@ def test_update_custom_primary_key(self):
def test_empty_objects(self):
with self.assertNumQueries(0):
- Note.... | Include number of rows matched in bulk_update() return value
Description
Currently, bulk_update() returns None, unlike update(), which returns the number of rows matched.
It looks like it would be easy to add the same functionality to bulk_update() since bulk_update() simply calls update() repeatedly:
https://githu... | Also, if this feature is okayed, maybe the number could be returned in a way that would permit other useful numbers to be added to the return value in a backwards-compatible way later on. For example, the number could be returned as a property of a named tuple with one property. That way, if a new value is requested in... | 2021-06-26T05:38:46Z | 4.0 | ["test_empty_objects (queries.test_bulk_update.BulkUpdateTests)", "test_large_batch (queries.test_bulk_update.BulkUpdateTests)", "test_updated_rows_when_passing_duplicates (queries.test_bulk_update.BulkUpdateTests)"] | ["test_batch_size (queries.test_bulk_update.BulkUpdateNoteTests)", "test_foreign_keys_do_not_lookup (queries.test_bulk_update.BulkUpdateNoteTests)", "test_functions (queries.test_bulk_update.BulkUpdateNoteTests)", "test_multiple_fields (queries.test_bulk_update.BulkUpdateNoteTests)", "test_set_field_to_null (queries.te... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour |
django/django | django__django-14608 | 7f33c1e22dbc34a7afae7967783725b10f1f13b1 | diff --git a/django/forms/formsets.py b/django/forms/formsets.py
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -333,7 +333,7 @@ def full_clean(self):
self._non_form_errors.
"""
self._errors = []
- self._non_form_errors = self.error_class()
+ self._non_form_err... | diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -3348,7 +3348,10 @@ def test_non_form_errors_is_errorlist(self):
response = self.client.post(reverse('admin:admin_views_person_changelist'), data)
non_form_errors =... | Add `nonform` CSS class for non form errors in FormSets
Description
(last modified by Ties Jan Hefting)
Forms add the nonfield CSS class for non field errors in ErrorList instances. This is documented in a section on rendering form error messages. Similarly, in FormSets I'd expect to see the nonform CSS class ... | Seems reasonable (similar to #11776).
PR | 2021-07-07T19:51:30Z | 4.0 | ["If validate_max is set and max_num is less than TOTAL_FORMS in the", "If validate_min is set and min_num is more than TOTAL_FORMS in the", "test_non_form_errors (forms_tests.tests.test_formsets.FormsFormsetTestCase)", "test_non_form_errors_is_errorlist (admin_views.tests.AdminViewListEditable)"] | ["all_valid() validates all forms, even when some are invalid.", "test_valid (forms_tests.tests.test_formsets.AllValidTests)", "is_multipart() works with an empty formset.", "An empty formset still calls clean()", "Media is available on empty formset.", "test_customize_management_form_error (forms_tests.tests.test_form... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | <15 min fix |
django/django | django__django-14672 | 00ea883ef56fb5e092cbe4a6f7ff2e7470886ac4 | diff --git a/django/db/models/fields/reverse_related.py b/django/db/models/fields/reverse_related.py
--- a/django/db/models/fields/reverse_related.py
+++ b/django/db/models/fields/reverse_related.py
@@ -310,7 +310,7 @@ def __init__(self, field, to, related_name=None, related_query_name=None,
def identity(self):
... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -821,6 +821,33 @@ class Child(Parent):
)
])
+ def test_field_name_clash_with_m2m_through(self):... | Missing call `make_hashable` on `through_fields` in `ManyToManyRel`
Description
In 3.2 identity property has been added to all ForeignObjectRel to make it possible to compare them. A hash is derived from said identity and it's possible because identity is a tuple. To make limit_choices_to hashable (one of this tuple ... | 2021-07-20T10:47:34Z | 4.0 | ["test_multiple_autofields (invalid_models_tests.test_models.MultipleAutoFieldsTests)", "test_db_column_clash (invalid_models_tests.test_models.FieldNamesTests)", "test_ending_with_underscore (invalid_models_tests.test_models.FieldNamesTests)", "test_including_separator (invalid_models_tests.test_models.FieldNamesTests... | [] | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 15 min - 1 hour | |
django/django | django__django-14725 | 0af9a5fc7d765aa05ea784e2c3237675f3bb4b49 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -676,7 +676,10 @@ def save_m2m():
for form in self.saved_forms:
form.save_m2m()
self.save_m2m = save_m2m
- return self.save_existing_objects... | diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py
--- a/tests/model_formsets/tests.py
+++ b/tests/model_formsets/tests.py
@@ -1771,6 +1771,73 @@ def test_initial_form_count_empty_data(self):
formset = AuthorFormSet({})
self.assertEqual(formset.initial_form_count(), 0)
+ d... | Provide a way for model formsets to disallow new object creation
Description
Model formsets don't provide a way to create an "edit only" view of objects. We see users trying to use extra=0 to accomplish this, but that's not reliable as extra is merely meant for the extra number of forms to display. You can add more f... | In 8e6a08e: Refs #26142 -- Documented that Formset's extra=0 doesn't prevent creating objects.
In 204d31c: [1.9.x] Refs #26142 -- Documented that Formset's extra=0 doesn't prevent creating objects. Backport of 8e6a08e937272f088902cdbec65a9f2e919783bf from master
Doesn't max_num already allow this? Testing on master, if... | 2021-08-01T21:24:36Z | 4.1 | ["test_edit_only (model_formsets.tests.ModelFormsetTest)", "test_edit_only_inlineformset_factory (model_formsets.tests.ModelFormsetTest)", "test_edit_only_object_outside_of_queryset (model_formsets.tests.ModelFormsetTest)"] | ["Make sure that an add form that is filled out, but marked for deletion", "Make sure that a change form that is filled out, but marked for deletion", "test_deletion (model_formsets.tests.DeletionTests)", "test_outdated_deletion (model_formsets.tests.DeletionTests)", "test_callable_defaults (model_formsets.tests.ModelF... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
django/django | django__django-14787 | 004b4620f6f4ad87261e149898940f2dcd5757ef | diff --git a/django/utils/decorators.py b/django/utils/decorators.py
--- a/django/utils/decorators.py
+++ b/django/utils/decorators.py
@@ -37,7 +37,7 @@ def _wrapper(self, *args, **kwargs):
# 'self' argument, but it's a closure over self so it can call
# 'func'. Also, wrap method.__get__() in a functi... | diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py
--- a/tests/decorators/tests.py
+++ b/tests/decorators/tests.py
@@ -425,6 +425,29 @@ class Test:
def __module__(cls):
return "tests"
+ def test_wrapper_assignments(self):
+ """@method_decorator preserves... | method_decorator() should preserve wrapper assignments
Description
the function that is passed to the decorator is a partial object and does not have any of the attributes expected from a function i.e. __name__, __module__ etc...
consider the following case
def logger(func):
@wraps(func)
def inner(*args, **kwargs):... | 2021-08-23T12:59:59Z | 4.1 | ["@method_decorator preserves wrapper assignments."] | ["test_cache_control_decorator_http_request (decorators.tests.CacheControlDecoratorTest)", "Ensures @xframe_options_deny properly sets the X-Frame-Options header.", "Ensures @xframe_options_exempt properly instructs the", "Ensures @xframe_options_sameorigin properly sets the X-Frame-Options", "Built-in decorators set c... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | <15 min fix | |
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).
| 2021-10-16T09:31:21Z | 4.1 | ["test_rename_model_with_db_table_noop (migrations.test_operations.OperationTests)"] | ["test_references_model_mixin (migrations.test_operations.TestCreateModel)", "test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.Fiel... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | <15 min fix | |
django/django | django__django-15037 | dab48b7482295956973879d15bfd4d3bb0718772 | diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
--- a/django/core/management/commands/inspectdb.py
+++ b/django/core/management/commands/inspectdb.py
@@ -116,13 +116,17 @@ def table2model(table_name):
extra_params['unique'] = True
... | diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py
--- a/tests/inspectdb/models.py
+++ b/tests/inspectdb/models.py
@@ -21,6 +21,12 @@ class PeopleMoreData(models.Model):
license = models.CharField(max_length=255)
+class ForeignKeyToField(models.Model):
+ to_field_fk = models.ForeignKey(
+ ... | Foreign key to a specific field is not handled in inspectdb
Description
(last modified by Tim Graham)
if you have a DB like that
CREATE TABLE foo ( id serial primary key, other_id int UNIQUE);
CREATE TABLE bar (
id serial primary key, other_id int,
constraint myconst
FOREIGN KEY(other_id) references foo(oth... | simple patch to handle FK to non pk field.
it seems I cannot reproduce outside of my own code...
I will check it! | 2021-10-30T15:21:38Z | 4.1 | ["test_foreign_key_to_field (inspectdb.tests.InspectDBTestCase)"] | ["inspectdb --include-views creates models for database views.", "test_attribute_name_not_python_keyword (inspectdb.tests.InspectDBTestCase)", "test_char_field_db_collation (inspectdb.tests.InspectDBTestCase)", "Introspection of column names consist/start with digits (#16536/#17676)", "Test introspection of various Dja... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
django/django | django__django-15127 | 9a6e2df3a8f01ea761529bec48e5a8dc0ea9575b | diff --git a/django/contrib/messages/apps.py b/django/contrib/messages/apps.py
--- a/django/contrib/messages/apps.py
+++ b/django/contrib/messages/apps.py
@@ -1,7 +1,18 @@
from django.apps import AppConfig
+from django.contrib.messages.storage import base
+from django.contrib.messages.utils import get_level_tags
+from... | diff --git a/tests/messages_tests/base.py b/tests/messages_tests/base.py
--- a/tests/messages_tests/base.py
+++ b/tests/messages_tests/base.py
@@ -1,7 +1,7 @@
-from django.contrib.messages import constants, get_level, set_level, utils
+from django.contrib.messages import constants, get_level, set_level
from django.con... | LEVEL_TAGS not updated when using @override_settings
Description
When reading messages inside tests, new message tags created using @override_settings is not updated.
That causes the django.contrib.messages.storage.base.Message.level_tag property results to be an empty string and not know the new tags.
| If you aren't planning to provide a patch (with a test), could you provide some minimal code that demonstrates the issue?
LEVEL_TAGS is a constant defined in the django.contrib.messages.storage.base module that's why it needs to be updated after changing MESSAGE_TAGS (see #16574 and override_settings_tags() hook). It ... | 2021-11-25T13:14:38Z | 4.1 | ["test_override_settings_level_tags (messages_tests.tests.TestLevelTags)"] | ["test_eq (messages_tests.tests.MessageTests)"] | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | <15 min fix |
django/django | django__django-15128 | cb383753c0e0eb52306e1024d32a782549c27e61 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -572,6 +572,15 @@ def combine(self, rhs, connector):
if self.distinct_fields != rhs.distinct_fields:
raise TypeError('Cannot combine queries with di... | diff --git a/tests/queries/models.py b/tests/queries/models.py
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -613,13 +613,14 @@ def __str__(self):
class BaseUser(models.Model):
- pass
+ annotation = models.ForeignKey(Annotation, models.CASCADE, null=True, blank=True)
class Task(models.M... | Query.change_aliases raises an AssertionError
Description
Python Version: 3.9.2
Django Version: 2.2.24, 3.2.9 (reproduced using two different versions)
Code to Reproduce
# models.py
from django.db import models
class Foo(models.Model):
qux = models.ForeignKey("app.Qux", on_delete=models.CASCADE, related_name="foos"... | Thanks for the report. Reproduced at b8c0b22f2f0f8ce664642332d6d872f300c662b4.
Vishal Pandey, if you're looking for pointers on how to resolve the issue I think I have a pretty good understanding of the problem. The root cause is that both queries happen to share the same alias_prefix; the letter used generate aliases ... | 2021-11-25T15:50:24Z | 4.1 | ["test_conflicting_aliases_during_combine (queries.tests.QuerySetBitwiseOperationTests)"] | ["test_ticket14729 (queries.tests.RawQueriesTests)", "test_datetimes_invalid_field (queries.tests.Queries3Tests)", "test_ticket22023 (queries.tests.Queries3Tests)", "test_ticket7107 (queries.tests.Queries3Tests)", "test_21001 (queries.tests.EmptyStringsAsNullTest)", "test_direct_exclude (queries.tests.EmptyStringsAsNul... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 1-4 hours |
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)"] | ["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
django/django | django__django-15315 | 652c68ffeebd510a6f59e1b56b3e007d07683ad8 | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -542,11 +542,7 @@ def __lt__(self, other):
return NotImplemented
def __hash__(self):
- return hash((
- self.crea... | diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -128,9 +128,14 @@ class InheritAbstractModel2(AbstractModel):
self.assertLess(abstract_model_field, inherit2_model_field)
self.assertLess(inherit1_model_field, ... | Model Field.__hash__() should be immutable.
Description
Field.__hash__ changes value when a field is assigned to a model class.
This code crashes with an AssertionError:
from django.db import models
f = models.CharField(max_length=200)
d = {f: 1}
class Book(models.Model):
title = f
assert f in d
The bug was introduc... | 2022-01-13T18:51:58Z | 4.1 | ["test_hash_immutability (model_fields.tests.BasicFieldTests)"] | ["test_check (model_fields.tests.ChoicesTests)", "test_choices (model_fields.tests.ChoicesTests)", "test_flatchoices (model_fields.tests.ChoicesTests)", "test_formfield (model_fields.tests.ChoicesTests)", "test_invalid_choice (model_fields.tests.ChoicesTests)", "test_blank_in_choices (model_fields.tests.GetChoicesTests... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | <15 min fix | |
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)"] | ["test_equal (expressions.tests.OrderByTests)", "test_hash (expressions.tests.OrderByTests)", "test_aggregates (expressions.tests.ReprTests)", "test_distinct_aggregates (expressions.tests.ReprTests)", "test_expressions (expressions.tests.ReprTests)", "test_filtered_aggregates (expressions.tests.ReprTests)", "test_funct... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
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"] | ["test_supports_json_field_operational_error (backends.sqlite.test_features.FeaturesTests)", "test_fixtures_loaded (fixtures_regress.tests.TestLoadFixtureFromOtherAppDirectory)", "M2M relations with explicit through models should NOT count as", "Circular M2M relations with explicit through models should be serializable... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
django/django | django__django-15561 | 6991880109e35c879b71b7d9d9c154baeec12b89 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -1376,22 +1376,9 @@ def _field_should_be_altered(self, old_field, new_field):
# - changing only a field name
# - changing an attribute t... | diff --git a/tests/schema/tests.py b/tests/schema/tests.py
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -3961,6 +3961,20 @@ def test_alter_field_fk_attributes_noop(self):
with connection.schema_editor() as editor, self.assertNumQueries(0):
editor.alter_field(Book, new_field, old_fiel... | AlterField operation should be noop when adding/changing choices on SQLite.
Description
while writing a test case for #33470 i found that for sqlite, even a seemingly db-transparent change like adding choices still generates sql (new table + insert + drop + rename) even though this shouldn't be needed. on e.g. postgr... | It was missed in #25253 (see 9159d173c3822312c653db7ff5b9a94b14af1dca). Adding choices to the non_database_attrs should fix it: django/db/backends/base/schema.py diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 4cd4567cbc..822da656d3 100644 a b class BaseDatabaseSchemaEditor: 113... | 2022-04-01T18:29:04Z | 4.1 | ["test_alter_field_choices_noop (schema.tests.SchemaTests)"] | ["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
django/django | django__django-15563 | 9ffd4eae2ce7a7100c98f681e2b6ab818df384a4 | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1836,7 +1836,23 @@ def pre_sql_setup(self):
query.clear_ordering(force=True)
query.extra = {}
query.select = []
- query.add... | diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -667,3 +667,15 @@ def test_create_new_instance_with_pk_equals_none_multi_inheritance(self):
Politician.objects.ge... | Wrong behavior on queryset update when multiple inheritance
Description
Queryset update has a wrong behavior when queryset class inherits multiple classes. The update happens not on child class but on other parents class instances.
Here an easy example to show the problem:
class Base(models.Model):
base_id = models.... | Thank you for your report. Confirmed this is another issue with concrete MTI. I've looked at the code and in order to address the issue both sql.UpdateQuery and sql.SQLUpdateCompiler need to be updated. The changes revolve around changing UpdateQuery.related_ids: list[int] to related_ids: dict[Model, list[int]] and mak... | 2022-04-06T02:48:01Z | 4.1 | ["test_mti_update_grand_parent_through_child (model_inheritance_regress.tests.ModelInheritanceTest)", "test_mti_update_parent_through_child (model_inheritance_regress.tests.ModelInheritanceTest)"] | ["test_abstract_base_class_m2m_relation_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_abstract_base_class_m2m_relation_inheritance_manager_reused (model_inheritance_regress.tests.ModelInheritanceTest)", "verbose_name_plural correctly inherited from ABC if inheritance chain", "Regression tes... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 15 min - 1 hour |
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)"] | ["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_subquery_usage (custom_lookups.tests.SubqueryTransformTests)", "test_call_order (custom_lookups.tests.LookupTransformCallOrderTests)", "test_overridden_get_lookup (cu... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | <15 min fix |
django/django | django__django-15629 | 694cf458f16b8d340a3195244196980b2dec34fd | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -823,13 +823,15 @@ def _alter_field(
self.execute(self._delete_unique_sql(model, constraint_name))
# Drop incoming FK constraint... | diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -65,6 +65,16 @@ def assertColumnNull(self, table, column, using="default"):
def assertColumnNotNull(self, table, column, using="default"):
self.assertFalse(... | Errors with db_collation – no propagation to foreignkeys
Description
(last modified by typonaut)
Using db_collation with a pk that also has referenced fks in other models causes foreign key constraint errors in MySQL.
With the following models:
class Account(models.Model):
id = ShortUUIDField(primary_key=True,... | It seems like this should be addressable by defining a ForeignKey.db_collation property that proxies self.target_field.db_column django/db/models/fields/related.py diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 11407ac902..f82f787f5c 100644 a b def db_type(self, connection):... | 2022-04-23T21:58:24Z | 4.1 | ["AlterField operation of db_collation on primary keys changes any FKs", "Creation of models with a FK to a PK with db_collation."] | ["test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.FieldOperationTests)", "test_references_field_by_remote_field_model (migrations.... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | 1-4 hours |
django/django | django__django-15741 | 8c0886b068ba4e224dd78104b93c9638b860b398 | diff --git a/django/utils/formats.py b/django/utils/formats.py
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -113,6 +113,7 @@ def get_format(format_type, lang=None, use_l10n=None):
use_l10n = settings.USE_L10N
if use_l10n and lang is None:
lang = get_language()
+ format_ty... | diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1518,6 +1518,9 @@ def test_get_format_modules_lang(self):
with translation.override("de", deactivate=True):
self.assertEqual(".", get_format("DECIMAL_SEPARATOR", lang="en"))
+ def te... | django.utils.formats.get_format should allow lazy parameter
Description
Commit [659d2421c7adb] (fixing #20296) triggered a regression when the date template filter (possibly others are affected too) receives a lazy string, like in some_date|date:_('Y-m-d').
This fails with: TypeError: getattr(): attribute name must b... | 2022-05-28T09:52:42Z | 4.2 | ["test_date_lazy (template_tests.filter_tests.test_date.DateTests)", "test_get_format_lazy_format (i18n.tests.FormattingTests)"] | ["test_lazy (i18n.tests.TestModels)", "test_safestr (i18n.tests.TestModels)", "get_language_info return the first fallback language info if the lang_info", "test_localized_language_info (i18n.tests.TestLanguageInfo)", "test_unknown_language_code (i18n.tests.TestLanguageInfo)", "test_unknown_language_code_and_country_co... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-15814 | 5eb6a2b33d70b9889e1cafa12594ad6f80773d3a | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -748,6 +748,7 @@ def deferred_to_data(self, target):
cur_model = source.related_model
else:
cur_model = source.... | diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py
--- a/tests/proxy_models/tests.py
+++ b/tests/proxy_models/tests.py
@@ -395,6 +395,12 @@ def test_proxy_load_from_fixture(self):
p = MyPerson.objects.get(pk=100)
self.assertEqual(p.name, "Elvis Presley")
+ def test_select_rela... | QuerySet.only() after select_related() crash on proxy models.
Description
When I optimize a query using select_related() and only() methods from the proxy model I encounter an error:
Windows 10; Python 3.10; Django 4.0.5
Traceback (most recent call last):
File "D:\study\django_college\manage.py", line 22, in <module... | Thanks for the report. Would you like to prepare a patch? A regression test is required, e.g. tests/proxy_models/tests.py diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index f2f465678b..2081c0cbe3 100644 a b class ProxyModelTests(TestCase): 390390 repr(resp), "<ProxyImprovement: ProxyImprovemen... | 2022-07-03T19:10:56Z | 4.2 | ["test_select_related_only (proxy_models.tests.ProxyModelTests)"] | ["test_abstract_base_with_model_fields (proxy_models.tests.ProxyModelTests)", "Creating a Person makes them accessible through the MyPerson proxy.", "A new MyPerson also shows up as a standard Person.", "test_concrete_model (proxy_models.tests.ProxyModelTests)", "test_content_type (proxy_models.tests.ProxyModelTests)",... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-15863 | 37c5b8c07be104fd5288cd87f101e48cb7a40298 | diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -149,7 +149,7 @@ def floatformat(text, arg=-1):
use_l10n = False
arg = arg[:-1] or -1
try:
- input_val = repr(text)
... | diff --git a/tests/template_tests/filter_tests/test_floatformat.py b/tests/template_tests/filter_tests/test_floatformat.py
--- a/tests/template_tests/filter_tests/test_floatformat.py
+++ b/tests/template_tests/filter_tests/test_floatformat.py
@@ -56,6 +56,10 @@ def test_inputs(self):
self.assertEqual(floatform... | Filter floatformat drops precision in decimal numbers
Description
I discovered that floatformat template filter may drop precision when used for Decimal numbers.
MWE:
from decimal import Decimal
from django import setup
from django.conf import settings
from django.template import Template, Context
TEMPLATES = [
{
... | 2022-07-20T12:58:04Z | 4.2 | ["test_inputs (template_tests.filter_tests.test_floatformat.FunctionTests)"] | ["test_floatformat01 (template_tests.filter_tests.test_floatformat.FloatformatTests)", "test_floatformat02 (template_tests.filter_tests.test_floatformat.FloatformatTests)", "test_float_dunder_method (template_tests.filter_tests.test_floatformat.FunctionTests)", "test_force_grouping (template_tests.filter_tests.test_flo... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-15973 | 2480554dc4ada4ecf3f6a08e318735a2e50783f3 | diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -1422,7 +1422,7 @@ def _get_dependencies_for_foreign_key(app_label, model_name, field, project_stat
dependencies = [(dep_app_label, d... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -3585,6 +3585,52 @@ def test_create_with_through_model(self):
changes, "testapp", 0, 3, model_name="author", name="publishers... | Defining the "through" model in a many-to-many field in another app causes "AttributeError: 'str' object has no attribute '_meta'" on migration
Description
I tried migrating my apps into the database, the three relevant apps are called: "fonte", "fonte_variavel" and "variavel". fonte and variavel models have a many-t... | I was able to reproduce the problem with your models. Moving the FonteVariavelModel model to the fonte app seems to work. Even if there's a bug in Django, as a workaround, why not simply move the model? | 2022-08-19T18:10:02Z | 4.2 | ["test_create_with_through_model_separate_apps (migrations.test_autodetector.AutodetectorTests)"] | ["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16032 | 0c3981eb5094419fe200eb46c71b5376a2266166 | diff --git a/django/db/models/fields/related_lookups.py b/django/db/models/fields/related_lookups.py
--- a/django/db/models/fields/related_lookups.py
+++ b/django/db/models/fields/related_lookups.py
@@ -93,7 +93,6 @@ def get_prep_lookup(self):
elif not getattr(self.rhs, "has_select_fields", True) and not g... | diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -989,6 +989,34 @@ def test_annotation_filter_with_subquery(self):
publisher_books_qs, [{"name": "Sams"}, {"name": "Morgan Kaufmann"}]
)
+ def test_annotati... | __in doesn't clear selected fields on the RHS when QuerySet.alias() is used after annotate().
Description
Here is a test case to reproduce the bug, you can add this in tests/annotations/tests.py
def test_annotation_and_alias_filter_in_subquery(self):
long_books_qs = (
Book.objects.filter(
pages__gt=400,
... | This is a documented and expected behavior.
Using either .alias or .annotate works as expected without using .values to limit to 1 column. Why is that? but using both of them doesn't seem work.
Replying to Gabriel Muj: Using either .alias or .annotate works as expected without using .values to limit to 1 column. Why i... | 2022-09-06T09:54:57Z | 4.2 | ["test_annotation_and_alias_filter_in_subquery (annotations.tests.NonAggregateAnnotationTestCase)", "test_annotation_and_alias_filter_related_in_subquery (annotations.tests.NonAggregateAnnotationTestCase)"] | ["test_aggregate_alias (annotations.tests.AliasTests)", "test_alias_after_annotation (annotations.tests.AliasTests)", "test_alias_annotate_with_aggregation (annotations.tests.AliasTests)", "test_alias_annotation_expression (annotations.tests.AliasTests)", "test_alias_default_alias_expression (annotations.tests.AliasTes... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | 15 min - 1 hour |
django/django | django__django-16100 | c6350d594c359151ee17b0c4f354bb44f28ff69e | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -2011,15 +2011,17 @@ def changelist_view(self, request, extra_context=None):
)
if formset.is_valid():
changecount = 0
-... | diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -1,4 +1,5 @@
import datetime
+from unittest import mock
from django.contrib import admin
from django.contrib.admin.models import LogEntry
@@ -16,12 +17,12 @@... | Add transaction handling to Changelist list_editable processing.
Description
It seems that changelist_view in Django admin is missing a transaction. Since the view may change data in database, it should be wrapped in a transaction to prevent unexpected states in case of errors.
| So, this has never been wrapped in a transaction. See https://github.com/django/django/commit/7bc0878922 where it was added. Happy to accept as a New Feature to investigate adding that. (I can't immediately see any obvious blockers.) | 2022-09-24T13:32:02Z | 4.2 | ["test_list_editable_atomicity (admin_changelist.tests.ChangeListTests)"] | ["{% get_admin_log %} works if the user model's primary key isn't named", "test_missing_args (admin_changelist.tests.GetAdminLogTests)", "{% get_admin_log %} works without specifying a user.", "test_non_integer_limit (admin_changelist.tests.GetAdminLogTests)", "test_without_as (admin_changelist.tests.GetAdminLogTests)"... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16116 | 5d36a8266c7d5d1994d7a7eeb4016f80d9cb0401 | diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -70,7 +70,10 @@ def add_arguments(self, parser):
"--check",
acti... | diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -2391,9 +2391,10 @@ def test_makemigrations_check(self):
makemigrations --check should exit with a non-zero status when
there are change... | makemigrations --check generating migrations is inconsistent with other uses of --check
Description
To script a check for missing migrations but without actually intending to create the migrations, it is necessary to use both --check and --dry-run, which is inconsistent with migrate --check and optimizemigration --ch... | I think this makes sense. | 2022-09-25T23:54:49Z | 4.2 | ["makemigrations --check should exit with a non-zero status when"] | ["test_makemigrations_app_name_specified_as_label (migrations.test_commands.AppLabelErrorTests)", "test_makemigrations_nonexistent_app_label (migrations.test_commands.AppLabelErrorTests)", "test_migrate_app_name_specified_as_label (migrations.test_commands.AppLabelErrorTests)", "test_migrate_nonexistent_app_label (migr... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16255 | 444b6da7cc229a58a2c476a52e45233001dc7073 | diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
--- a/django/contrib/sitemaps/__init__.py
+++ b/django/contrib/sitemaps/__init__.py
@@ -167,7 +167,7 @@ def get_latest_lastmod(self):
return None
if callable(self.lastmod):
try:
- ret... | diff --git a/tests/sitemaps_tests/test_http.py b/tests/sitemaps_tests/test_http.py
--- a/tests/sitemaps_tests/test_http.py
+++ b/tests/sitemaps_tests/test_http.py
@@ -507,6 +507,16 @@ def test_callable_sitemod_full(self):
self.assertXMLEqual(index_response.content.decode(), expected_content_index)
sel... | Sitemaps without items raise ValueError on callable lastmod.
Description
When sitemap contains not items, but supports returning lastmod for an item, it fails with a ValueError:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
res... | Thanks for the report.
The default argument of max() can be used. | 2022-11-04T13:49:40Z | 4.2 | ["test_callable_sitemod_no_items (sitemaps_tests.test_http.HTTPSitemapTests)"] | ["A simple sitemap index can be rendered with a custom template", "test_simple_sitemap_custom_index_warning (sitemaps_tests.test_http.DeprecatedTests)", "A i18n sitemap with alternate/hreflang links can be rendered.", "A i18n sitemap index with limited languages can be rendered.", "A i18n sitemap index with x-default c... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix |
django/django | django__django-16333 | 60a7bd89860e504c0c33b02c78edcac87f6d1b5a | diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -141,6 +141,8 @@ def save(self, commit=True):
user.set_password(self.cleaned_data["password1"])
if commit:
user.save()
+ if hasattr(... | diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py
--- a/tests/auth_tests/test_forms.py
+++ b/tests/auth_tests/test_forms.py
@@ -35,6 +35,7 @@
)
from .models.with_custom_email_field import CustomEmailField
from .models.with_integer_username import IntegerUsernameUser
+from .models.with_many... | UserCreationForm should save data from ManyToMany form fields
Description
When using contrib.auth.forms.UserCreationForm with a custom User model which has ManyToManyField fields, the data in all related form fields (e.g. a ModelMultipleChoiceField) is not saved.
This is because unlike its parent class django.forms.... | 2022-11-27T20:09:15Z | 4.2 | ["test_custom_form_saves_many_to_many_field (auth_tests.test_forms.UserCreationFormTest)"] | ["test_field_order (auth_tests.test_forms.PasswordChangeFormTest)", "test_html_autocomplete_attributes (auth_tests.test_forms.PasswordChangeFormTest)", "test_incorrect_password (auth_tests.test_forms.PasswordChangeFormTest)", "test_password_verification (auth_tests.test_forms.PasswordChangeFormTest)", "test_password_wh... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | <15 min fix | |
django/django | django__django-16493 | e3a4cee081cf60650b8824f0646383b79cb110e7 | diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -295,8 +295,9 @@ def deconstruct(self):
if kwargs.get("max_length") == 100:
del kwargs["max_length"]
kwargs["upload_to"] = self... | diff --git a/tests/file_storage/models.py b/tests/file_storage/models.py
--- a/tests/file_storage/models.py
+++ b/tests/file_storage/models.py
@@ -9,7 +9,7 @@
import tempfile
from pathlib import Path
-from django.core.files.storage import FileSystemStorage
+from django.core.files.storage import FileSystemStorage, d... | Callable storage on FileField fails to deconstruct when it returns default_storage
Description
If the storage argument on a FileField is set to a callable that returns default_storage, it is omitted from the deconstructed form of the field, rather than being included as a reference to the callable as expected.
For ex... | Yes, OK. That looks correct. We're essentially saying that when hasattr(self, "_storage_callable") that should unconditionally be used by deconstruct. 🤔
We should probably use getattr(self, "_storage_callable", self.storage) in both lines. | 2023-01-20T18:29:25Z | 5.0 | ["A callable that returns default_storage is not omitted when"] | ["test_deconstruction (file_storage.tests.FileSystemStorageTests.test_deconstruction)", "FileSystemStorage.__init__() shouldn't evaluate base_url.", "test_deprecation_warning (file_storage.tests.GetStorageClassTests.test_deprecation_warning)", "get_storage_class returns the class for a storage backend name/path.", "get... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16502 | 246eb4836a6fb967880f838aa0d22ecfdca8b6f1 | diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -11,6 +11,7 @@
import socket
import socketserver
import sys
+from collections import deque
from wsgiref import simple_server
from django.core.exceptions im... | diff --git a/tests/servers/test_basehttp.py b/tests/servers/test_basehttp.py
--- a/tests/servers/test_basehttp.py
+++ b/tests/servers/test_basehttp.py
@@ -1,4 +1,5 @@
from io import BytesIO
+from socketserver import ThreadingMixIn
from django.core.handlers.wsgi import WSGIRequest
from django.core.servers.basehttp ... | After #26052 runserver returns response body for HTTP HEAD requests
Description
For compliance with RFC 2616, section 4.3, response bodies must not be returned for HEAD requests.
In #26052, the stripping of the response bodies was removed from Django in favour of letting the server perform the body removal, since the... | Also this comment now seems incorrect: https://github.com/django/django/blob/5d3b322dce452dd75e8602ced9f0d02f9d6a5837/django/middleware/http.py#L15-L19 ...in that the body won't be empty as far as middleware is concerned for HEAD requests. The spec says entity tag validators can still be set for HEAD requests: https:... | 2023-01-26T09:21:31Z | 5.0 | ["test_no_body_returned_for_head_requests (servers.test_basehttp.WSGIRequestHandlerTestCase.test_no_body_returned_for_head_requests)"] | ["test_https (servers.test_basehttp.WSGIRequestHandlerTestCase.test_https)", "test_log_message (servers.test_basehttp.WSGIRequestHandlerTestCase.test_log_message)", "WSGIRequestHandler ignores headers containing underscores.", "WSGIServer handles broken pipe errors."] | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16527 | bd366ca2aeffa869b7dbc0b0aa01caea75e6dc31 | diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py
--- a/django/contrib/admin/templatetags/admin_modify.py
+++ b/django/contrib/admin/templatetags/admin_modify.py
@@ -100,7 +100,7 @@ def submit_row(context):
and context.get("show_delete", ... | diff --git a/tests/admin_views/test_templatetags.py b/tests/admin_views/test_templatetags.py
--- a/tests/admin_views/test_templatetags.py
+++ b/tests/admin_views/test_templatetags.py
@@ -3,6 +3,7 @@
from django.contrib.admin import ModelAdmin
from django.contrib.admin.templatetags.admin_list import date_hierarchy
fr... | "show_save_as_new" in admin can add without this permission
Description
(last modified by Mariusz Felisiak)
At "django/contrib/admin/templatetags/admin_modify.py" file, line 102, I think you must put one more verification for this tag: "and has_add_permission", because "save_as_new" is a add modification.
I rew... | Thanks for the report. It was previously reported in #5650 and #3817, and #3817 was closed but only with a fix for "Save and add another" (see 825f0beda804e48e9197fcf3b0d909f9f548aa47). I rewrite this for my project: "show_save_as_new": not is_popup and has_add_permission # This line that I put!!! and has_change_permis... | 2023-02-05T22:05:00Z | 5.0 | ["test_submit_row_save_as_new_add_permission_required (admin_views.test_templatetags.AdminTemplateTagsTest.test_submit_row_save_as_new_add_permission_required)"] | ["test_choice_links (admin_views.test_templatetags.DateHierarchyTests.test_choice_links)", "test_choice_links_datetime (admin_views.test_templatetags.DateHierarchyTests.test_choice_links_datetime)", "admin_modify template tags follow the standard search pattern", "admin_list template tags follow the standard search pat... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16560 | 51c9bb7cd16081133af4f0ab6d06572660309730 | diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -32,6 +32,7 @@ def __init__(
condition=None,
deferrable=None,
include=None,
+ violation_error_code=N... | diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
--- a/tests/constraints/tests.py
+++ b/tests/constraints/tests.py
@@ -77,17 +77,26 @@ def test_custom_violation_error_message_clone(self):
"custom base_name message",
)
+ def test_custom_violation_code_message(self):
+ ... | Allow to customize the code attribute of ValidationError raised by BaseConstraint.validate
Description
It is currently possible to customize the violation_error_message of a ValidationError raised by a constraint but not the code.
I'd like to add a new violation_error_message parameter to BaseConstraint to allow to e... | Replying to xafer: It is currently possible to customize the violation_error_message of a ValidationError raised by a constraint but not the code. I'd like to add a new violation_error_message parameter to BaseConstraint to allow to easily add one. Agreed, adding violation_error_code sounds like a good idea as we have ... | 2023-02-16T10:45:56Z | 5.0 | ["test_custom_violation_code_message (constraints.tests.BaseConstraintTests.test_custom_violation_code_message)", "test_deconstruction (constraints.tests.BaseConstraintTests.test_deconstruction)", "test_eq (constraints.tests.CheckConstraintTests.test_eq)", "test_repr_with_violation_error_code (constraints.tests.CheckCo... | ["test_constraint_sql (constraints.tests.BaseConstraintTests.test_constraint_sql)", "test_contains_expressions (constraints.tests.BaseConstraintTests.test_contains_expressions)", "test_create_sql (constraints.tests.BaseConstraintTests.test_create_sql)", "test_custom_violation_error_message (constraints.tests.BaseConstr... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 1-4 hours |
django/django | django__django-16569 | 278881e37619278789942513916acafaa88d26f3 | diff --git a/django/forms/formsets.py b/django/forms/formsets.py
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -490,7 +490,9 @@ def add_fields(self, form, index):
required=False,
widget=self.get_ordering_widget(),
)
- if self.can_delet... | diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -1480,6 +1480,7 @@ def test_disable_delete_extra_formset_forms(self):
self.assertIn("DELETE", formset.forms[0].fields... | Formsets' add_fields() method fails in some circumstances if the argument index is None.
Description
Formsets' add_fields() method fails in some circumstances if the argument index is None.
When a FormSet has the attributes self.can_delete == True and self.can_delete_extra == False, calling the add_fields() method on... | 2023-02-17T20:11:38Z | 5.0 | ["test_disable_delete_extra_formset_forms (forms_tests.tests.test_formsets.FormsFormsetTestCase.test_disable_delete_extra_formset_forms)", "test_disable_delete_extra_formset_forms (forms_tests.tests.test_formsets.Jinja2FormsFormsetTestCase.test_disable_delete_extra_formset_forms)"] | ["all_valid() validates all forms, even when some are invalid.", "test_valid (forms_tests.tests.test_formsets.AllValidTests.test_valid)", "is_multipart() works with an empty formset.", "An empty formset still calls clean()", "Media is available on empty formset.", "test_as_div (forms_tests.tests.test_formsets.FormsetAs... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix | |
django/django | django__django-16595 | f9fe062de5fc0896d6bbbf3f260b5c44473b3c77 | diff --git a/django/db/migrations/operations/fields.py b/django/db/migrations/operations/fields.py
--- a/django/db/migrations/operations/fields.py
+++ b/django/db/migrations/operations/fields.py
@@ -247,9 +247,9 @@ def migration_name_fragment(self):
return "alter_%s_%s" % (self.model_name_lower, self.name_lowe... | diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py
--- a/tests/migrations/test_optimizer.py
+++ b/tests/migrations/test_optimizer.py
@@ -221,10 +221,10 @@ def test_create_alter_owrt_delete_model(self):
migrations.AlterOrderWithRespectTo("Foo", "a")
)
- def _t... | Migration optimizer does not reduce multiple AlterField
Description
Let's consider the following operations:
operations = [
migrations.AddField(
model_name="book",
name="title",
field=models.CharField(max_length=256, null=True),
),
migrations.AlterField(
model_name="book",
name="title",
field=models.C... | Your analysis is correct Laurent, the reduction of multiple AlterField against the same model is simply not implemented today hence why you're running into this behaviour. Given you're already half way there I would encourage you to submit a PR that adds these changes and an optimizer regression test to cover them if... | 2023-02-24T10:30:35Z | 5.0 | ["test_alter_alter_field (migrations.test_optimizer.OptimizerTests.test_alter_alter_field)"] | ["AlterField should optimize into AddField.", "RemoveField should cancel AddField", "RenameField should optimize into AddField", "test_alter_alter_index_model (migrations.test_optimizer.OptimizerTests.test_alter_alter_index_model)", "test_alter_alter_owrt_model (migrations.test_optimizer.OptimizerTests.test_alter_alter... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix |
django/django | django__django-16631 | 9b224579875e30203d079cc2fee83b116d98eb78 | diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
--- a/django/contrib/auth/__init__.py
+++ b/django/contrib/auth/__init__.py
@@ -199,12 +199,26 @@ def get_user(request):
# Verify the session
if hasattr(user, "get_session_auth_hash"):
session_hash ... | diff --git a/tests/auth_tests/test_basic.py b/tests/auth_tests/test_basic.py
--- a/tests/auth_tests/test_basic.py
+++ b/tests/auth_tests/test_basic.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.contrib.auth import get_user, get_user_model
from django.contrib.auth.models import AnonymousUser, User
... | SECRET_KEY_FALLBACKS is not used for sessions
Description
I recently rotated my secret key, made the old one available in SECRET_KEY_FALLBACKS and I'm pretty sure everyone on our site is logged out now.
I think the docs for SECRET_KEY_FALLBACKS may be incorrect when stating the following:
In order to rotate your sec... | Hi! I'm a colleague of Eric's, and we were discussing some of the ramifications of fixing this issue and I thought I'd write them here for posterity. In particular for user sessions, using fallback keys in the AuthenticationMiddleware/auth.get_user(request) will keep existing _auth_user_hash values from before the rota... | 2023-03-06T15:19:52Z | 5.0 | ["test_get_user_fallback_secret (auth_tests.test_basic.TestGetUser.test_get_user_fallback_secret)"] | ["test_get_user (auth_tests.test_basic.TestGetUser.test_get_user)", "test_get_user_anonymous (auth_tests.test_basic.TestGetUser.test_get_user_anonymous)", "The current user model can be retrieved", "Check the creation and properties of a superuser", "test_superuser_no_email_or_password (auth_tests.test_basic.BasicTestC... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 1-4 hours |
django/django | django__django-16642 | fbe850106b2e4b85f838219cb9e1df95fba6c164 | diff --git a/django/http/response.py b/django/http/response.py
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -609,7 +609,9 @@ def set_headers(self, filelike):
# Encoding isn't set to prevent browsers from automatically
# uncompressing files.
content_ty... | diff --git a/tests/responses/test_fileresponse.py b/tests/responses/test_fileresponse.py
--- a/tests/responses/test_fileresponse.py
+++ b/tests/responses/test_fileresponse.py
@@ -253,8 +253,10 @@ def test_compressed_response(self):
"""
test_tuples = (
(".tar.gz", "application/gzip"),
+ ... | Improper guessing of Mime Type for "br" and "Z" file types
Description
Below FileResponse will set the content type as text/html, even if the last file extension is "Z' or "br".
FileResponse(open('test.html.Z', 'rb'))
FileResponse(open('test.html.br', 'rb'))
| Thanks for the report! | 2023-03-11T07:38:47Z | 5.0 | ["If compressed responses are served with the uncompressed Content-Type"] | ["Headers are set correctly with a buffer when an absolute filename is", "test_content_disposition_buffer (responses.test_fileresponse.FileResponseTests.test_content_disposition_buffer)", "test_content_disposition_buffer_attachment (responses.test_fileresponse.FileResponseTests.test_content_disposition_buffer_attachmen... | 4a72da71001f154ea60906a2f74898d32b7322a7 | <15 min fix |
django/django | django__django-16662 | 0eb3e9bd754e4c9fac8b616b705178727fc8031e | diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py
--- a/django/db/migrations/writer.py
+++ b/django/db/migrations/writer.py
@@ -175,7 +175,10 @@ def as_string(self):
# Sort imports by the package / module to be imported (the part after
# "from" in "from ... import ..." or ... | diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -7,6 +7,7 @@
import pathlib
import re
import sys
+import time
import uuid
import zoneinfo
from types import NoneType
@@ -912,13 +913,18 @@ def test_sorted_i... | Migration import ordering violates coding style and isort defaults
Description
New migration files are generated with imports sorted by module, independent of import style. For example:
import datetime
from django.db import migrations, models
import time
The Django coding style specifies:
Place all import module sta... | Normally I would reject this ticket as migrations are auto-generated code and it's not worth adding complicated logic to make them fully isort-compatible. However, this is a small tweak, so I'm happy to make it a slightly more accurate. Please send patch via a GitHub PR. | 2023-03-18T18:07:18Z | 5.0 | ["#24155 - Tests ordering of imports."] | ["test_args_kwargs_signature (migrations.test_writer.OperationWriterTests.test_args_kwargs_signature)", "test_args_signature (migrations.test_writer.OperationWriterTests.test_args_signature)", "test_empty_signature (migrations.test_writer.OperationWriterTests.test_empty_signature)", "test_expand_args_signature (migrati... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
django/django | django__django-16901 | ee36e101e8f8c0acde4bb148b738ab7034e902a0 | diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -6,6 +6,7 @@
from django.core.exceptions import EmptyResultSet, FullResultSet
from django.db.models.expressions import Case, When
+from django.db.models.functions imp... | diff --git a/tests/xor_lookups/tests.py b/tests/xor_lookups/tests.py
--- a/tests/xor_lookups/tests.py
+++ b/tests/xor_lookups/tests.py
@@ -19,6 +19,27 @@ def test_filter(self):
self.numbers[:3] + self.numbers[8:],
)
+ def test_filter_multiple(self):
+ qs = Number.objects.filter(
+ ... | On databases lacking XOR, Q(…) ^ Q(…) ^ Q(…) wrongly interpreted as exactly-one rather than parity
Description
On databases that don’t natively support XOR, such as PostgreSQL, Django generates incorrect fallback SQL for Q(…) ^ Q(…) ^ Q(…) with more than 2 arguments. The correct interpretation, and the interpretatio... | 2023-05-30T05:08:34Z | 5.0 | ["test_filter_multiple (xor_lookups.tests.XorLookupsTests.test_filter_multiple)"] | ["test_empty_in (xor_lookups.tests.XorLookupsTests.test_empty_in)", "test_exclude (xor_lookups.tests.XorLookupsTests.test_exclude)", "test_filter (xor_lookups.tests.XorLookupsTests.test_filter)", "test_filter_negated (xor_lookups.tests.XorLookupsTests.test_filter_negated)", "test_pk_q (xor_lookups.tests.XorLookupsTests... | 4a72da71001f154ea60906a2f74898d32b7322a7 | 15 min - 1 hour |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.