instance_id stringlengths 20 20 | feedback stringlengths 5 152 ⌀ | level int64 0 2 | erroneous_file stringlengths 21 49 | repo stringclasses 1
value | base_commit stringlengths 40 40 | patch stringlengths 386 2.03k | test_patch stringlengths 488 4.45k | problem_statement stringlengths 262 4.67k | hints_text stringlengths 0 9.06k | created_at stringdate 2019-02-03 11:30:12 2023-02-05 22:05:00 | version stringclasses 7
values | FAIL_TO_PASS stringlengths 52 310 | PASS_TO_PASS stringlengths 66 11.1k | environment_setup_commit stringclasses 7
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
django__django-15202 | Retreival is straightford correct file is the last stacktrace that has valid path | 1 | django/core/validators.py | django/django | 4fd3044ca0135da903a70dfb66992293f529ecf1 | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -108,15 +108,16 @@ def __call__(self, value):
raise ValidationError(self.message, code=self.code, params={'value': value})
# Then check full URL
+ try:
+ ... | diff --git a/tests/forms_tests/field_tests/test_urlfield.py b/tests/forms_tests/field_tests/test_urlfield.py
--- a/tests/forms_tests/field_tests/test_urlfield.py
+++ b/tests/forms_tests/field_tests/test_urlfield.py
@@ -100,6 +100,10 @@ def test_urlfield_clean_invalid(self):
# even on domains that don't fai... | URLField throws ValueError instead of ValidationError on clean
Description
forms.URLField( ).clean('////]@N.AN')
results in:
ValueError: Invalid IPv6 URL
Traceback (most recent call last):
File "basic_fuzzer.py", line 22, in TestOneInput
File "fuzzers.py", line 350, in test_forms_URLField
File "django/forms/f... | 2021-12-15T15:04:13Z | 4.1 | ["test_urlfield_clean_invalid (forms_tests.field_tests.test_urlfield.URLFieldTest)", "test_urlfield_clean_not_required (forms_tests.field_tests.test_urlfield.URLFieldTest)"] | ["test_urlfield_clean (forms_tests.field_tests.test_urlfield.URLFieldTest)", "test_urlfield_clean_required (forms_tests.field_tests.test_urlfield.URLFieldTest)", "test_urlfield_strip_on_none_value (forms_tests.field_tests.test_urlfield.URLFieldTest)", "test_urlfield_unable_to_set_strip_kwarg (forms_tests.field_tests.te... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | |
django__django-14017 | Retreival is straightford correct file is the last stacktrace that has valid path | 0 | django/db/models/query_utils.py | django/django | 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 |
django__django-11422 | manage.py has only one neigbour __init__. but next posisbke file was runserver according to description then it was able t find it using first neighbour | 0 | django/utils/autoreload.py | django/django | df46b329e0900e9e4dc1d60816c1dce6dfc1094e | diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -114,7 +114,15 @@ def iter_modules_and_files(modules, extra_files):
# During debugging (with PyDev) the 'typing.io' and 'typing.re' objects
# are added to sys.modul... | 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
@@ -132,6 +132,10 @@ def test_module_without_spec(self):
del module.__spec__
self.assertEqual(autoreload.iter_modules_and_files... | Autoreloader with StatReloader doesn't track changes in manage.py.
Description
(last modified by Mariusz Felisiak)
This is a bit convoluted, but here we go.
Environment (OSX 10.11):
$ python -V
Python 3.6.2
$ pip -V
pip 19.1.1
$ pip install Django==2.2.1
Steps to reproduce:
Run a server python manage.py runserv... | Thanks for the report. I simplified scenario. Regression in c8720e7696ca41f3262d5369365cc1bd72a216ca. Reproduced at 8d010f39869f107820421631111417298d1c5bb9.
Argh. I guess this is because manage.py isn't showing up in the sys.modules. I'm not sure I remember any specific manage.py handling in the old implementation, so... | 2019-05-27T19:15:21Z | 3.0 | ["test_main_module_is_resolved (utils_tests.test_autoreload.TestIterModulesAndFiles)"] | ["test_watchman_available (utils_tests.test_autoreload.GetReloaderTests)", "test_watchman_unavailable (utils_tests.test_autoreload.GetReloaderTests)", "test_calls_start_django (utils_tests.test_autoreload.RunWithReloaderTests)", "test_calls_sys_exit (utils_tests.test_autoreload.RunWithReloaderTests)", "test_swallows_ke... | 419a78300f7cd27611196e1e464d50fd0385ff27 |
django__django-14915 | 2 files related to given function name | 0 | django/forms/models.py | django/django | 903aaa35e5ceaa33bfc9b19b7f6da65ce5a91dd4 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -1166,6 +1166,9 @@ def __init__(self, value, instance):
def __str__(self):
return str(self.value)
+ def __hash__(self):
+ return hash(self.value)
+
def __eq__(self, ot... | diff --git a/tests/model_forms/test_modelchoicefield.py b/tests/model_forms/test_modelchoicefield.py
--- a/tests/model_forms/test_modelchoicefield.py
+++ b/tests/model_forms/test_modelchoicefield.py
@@ -2,7 +2,7 @@
from django import forms
from django.core.exceptions import ValidationError
-from django.forms.models... | ModelChoiceIteratorValue is not hashable.
Description
Recently I migrated from Django 3.0 to Django 3.1. In my code, I add custom data-* attributes to the select widget options. After the upgrade some of those options broke. Error is {TypeError}unhashable type: 'ModelChoiceIteratorValue'.
Example (this one breaks):
... | Thanks for the ticket. Agreed, we could make ModelChoiceIteratorValue hashable by adding: def __hash__(self): return hash(self.value) For now you can use value.value as documented in the "Backwards incompatible changes in 3.1" section. Would you like to prepare a patch?
Replying to Mariusz Felisiak: Thanks for the tic... | 2021-09-29T22:00:15Z | 4.1 | ["test_choice_value_hash (model_forms.test_modelchoicefield.ModelChoiceFieldTests)"] | ["test_basics (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_choice_iterator_passes_model_to_widget (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_choices (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_choices_bool (model_forms.test_modelchoicefield.ModelChoiceFi... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 |
django__django-15996 | Need to identify EnumSerializer as a function or a class | 0 | django/db/migrations/serializer.py | django/django | b30c0081d4d8a31ab7dc7f72a4c7099af606ef29 | diff --git a/django/db/migrations/serializer.py b/django/db/migrations/serializer.py
--- a/django/db/migrations/serializer.py
+++ b/django/db/migrations/serializer.py
@@ -16,7 +16,7 @@
from django.db.migrations.operations.base import Operation
from django.db.migrations.utils import COMPILED_REGEX_TYPE, RegexObject
f... | diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -413,6 +413,14 @@ def test_serialize_enum_flags(self):
"(2, migrations.test_writer.IntFlagEnum['B'])], "
"default=migrations.test_writer... | Support for serialization of combination of Enum flags.
Description
(last modified by Willem Van Onsem)
If we work with a field:
regex_flags = models.IntegerField(default=re.UNICODE | re.IGNORECASE)
This is turned into a migration with:
default=re.RegexFlag[None]
This is due to the fact that the EnumSerializer ... | patch of the EnumSerializer | 2022-08-25T04:49:14Z | 4.2 | ["test_serialize_enum_flags (migrations.test_writer.WriterTests)"] | ["test_args_kwargs_signature (migrations.test_writer.OperationWriterTests)", "test_args_signature (migrations.test_writer.OperationWriterTests)", "test_empty_signature (migrations.test_writer.OperationWriterTests)", "test_expand_args_signature (migrations.test_writer.OperationWriterTests)", "test_kwargs_signature (migr... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 |
django__django-15252 | null | 1 | django/db/migrations/executor.py | django/django | 361bb8f786f112ee275be136795c0b1ecefff928 | diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -96,8 +96,12 @@ def migrate(self, targets, plan=None, state=None, fake=False, fake_initial=False
(un)applied and in a second step run all the databas... | diff --git a/tests/backends/base/test_creation.py b/tests/backends/base/test_creation.py
--- a/tests/backends/base/test_creation.py
+++ b/tests/backends/base/test_creation.py
@@ -57,12 +57,12 @@ def test_custom_test_name_with_test_prefix(self):
@mock.patch.object(connection, 'ensure_connection')
@mock.patch.object(co... | MigrationRecorder does not obey db_router allow_migrate rules
Description
Hi,
We have a multi-db setup. We have one connection that is for the django project, and several connections that talk to other dbs for information (ie models with managed = False). Django should only create tables in the first connection, neve... | I don't think you've implemented your router correctly, but I'd need to check the router code to see if it's called multiple times (num_dbs*num_models) to be sure. This is how we implement our routers for allow_migrate: def allow_migrate(self, db, model): if db == 'other': return model._meta.app_label == 'legacy_app' #... | 2021-12-28T15:51:06Z | 4.1 | ["test_migrate_test_setting_false_ensure_schema (backends.base.test_creation.TestDbCreationTests)", "The django_migrations table is not created if there are no migrations"] | ["test_mark_expected_failures_and_skips (backends.base.test_creation.TestMarkTests)", "test_custom_test_name (backends.base.test_creation.TestDbSignatureTests)", "test_custom_test_name_with_test_prefix (backends.base.test_creation.TestDbSignatureTests)", "test_default_name (backends.base.test_creation.TestDbSignatureTe... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 |
django__django-11583 | null | 0 | django/utils/autoreload.py | django/django | 60dc957a825232fdda9138e2f8878b2ca407a7c9 | diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -143,6 +143,10 @@ def iter_modules_and_files(modules, extra_files):
# The module could have been removed, don't fail loudly if this
# is the case.
... | 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
@@ -140,6 +140,17 @@ def test_main_module_without_file_is_not_resolved(self):
fake_main = types.ModuleType('__main__')
self.ass... | Auto-reloading with StatReloader very intermittently throws "ValueError: embedded null byte".
Description
Raising this mainly so that it's tracked, as I have no idea how to reproduce it, nor why it's happening. It ultimately looks like a problem with Pathlib, which wasn't used prior to 2.2.
Stacktrace:
Traceback (mos... | Thanks for the report, however as you've admitted there is too many unknowns to accept this ticket. I don't believe that it is related with pathlib, maybe samba connection is unstable it's hard to tell.
I don't believe that it is related with pathlib Well ... it definitely is, you can see that from the stacktrace. The ... | 2019-07-21T20:56:14Z | 3.0 | ["test_path_with_embedded_null_bytes (utils_tests.test_autoreload.TestIterModulesAndFiles)", "test_paths_are_pathlib_instances (utils_tests.test_autoreload.TestIterModulesAndFiles)"] | ["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... | 419a78300f7cd27611196e1e464d50fd0385ff27 |
django__django-11620 | quite difficult to identify file as debug.py | 2 | django/views/debug.py | django/django | 514efa3129792ec2abb2444f3e7aeb3f21a38386 | diff --git a/django/views/debug.py b/django/views/debug.py
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -5,10 +5,10 @@
from pathlib import Path
from django.conf import settings
-from django.http import HttpResponse, HttpResponseNotFound
+from django.http import Http404, HttpResponse, HttpResponseNotFo... | diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -12,11 +12,13 @@
from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import DatabaseE... | When DEBUG is True, raising Http404 in a path converter's to_python method does not result in a technical response
Description
This is the response I get (plain text):
A server error occurred. Please contact the administrator.
I understand a ValueError should be raised which tells the URL resolver "this path does no... | It seems that other exceptions correctly result in a technical 500 response.
The technical_404_response view performs a new URL resolving (cf https://github.com/django/django/blob/a8e492bc81fca829f5d270e2d57703c02e58701e/django/views/debug.py#L482) which will obviously raise a new Http404 which won't be caught as only... | 2019-08-02T13:56:08Z | 3.0 | ["test_technical_404_converter_raise_404 (view_tests.tests.test_debug.DebugViewTests)"] | ["test_repr (view_tests.tests.test_debug.CallableSettingWrapperTests)", "test_cleanse_setting_basic (view_tests.tests.test_debug.HelperFunctionTests)", "test_cleanse_setting_ignore_case (view_tests.tests.test_debug.HelperFunctionTests)", "test_cleanse_setting_recurses_in_dictionary (view_tests.tests.test_debug.HelperFu... | 419a78300f7cd27611196e1e464d50fd0385ff27 |
django__django-16041 | need to identify that issue is with empty_form (file, function or class) | 1 | django/forms/formsets.py | django/django | 6df9398cce063874ae4d59db126d4adacb0fa8d3 | diff --git a/django/forms/formsets.py b/django/forms/formsets.py
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -257,14 +257,15 @@ def extra_forms(self):
@property
def empty_form(self):
- form = self.form(
- auto_id=self.auto_id,
- prefix=self.add_prefix("__pre... | 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
@@ -179,6 +179,10 @@ def test_form_kwargs_empty_form(self):
self.assertTrue(hasattr(formset.empty_form, "custom_kwarg"))... | Rendering empty_form crashes when empty_permitted is passed to form_kwargs
Description
Issue
When explicitly setting form_kwargs = {'empty_permitted':True} or form_kwargs = {'empty_permitted':False} , a KeyError occurs when rendering a template that uses a formset's empty_form.
Expected Behavior
empty_permitted is ig... | Thanks for the report. It should be enough to change form_kwargs for empty_form, e.g. django/forms/formsets.py diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 57676428ff..b73d1d742e 100644 a b class BaseFormSet(RenderableFormMixin): 257257 258258 @property 259259 def empty_form(self): 260 form = ... | 2022-09-09T10:07:29Z | 4.2 | ["test_empty_permitted_ignored_empty_form (forms_tests.tests.test_formsets.FormsFormsetTestCase)", "test_empty_permitted_ignored_empty_form (forms_tests.tests.test_formsets.Jinja2FormsFormsetTestCase)"] | ["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.", "Management forms are already rendered with the new div template."... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 |
django__django-13033 | Difficult to identify but can get an idea with sql statements and by considering file formats | 1 | django/db/models/sql/compiler.py | django/django | a59de6e89e8dc1f3e71c9a5a5bbceb373ea5247e | 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
@@ -727,7 +727,12 @@ def find_ordering_name(self, name, opts, alias=None, default_order='ASC',
# If we get to this point and the field is a relation to ... | diff --git a/tests/ordering/models.py b/tests/ordering/models.py
--- a/tests/ordering/models.py
+++ b/tests/ordering/models.py
@@ -18,6 +18,7 @@
class Author(models.Model):
name = models.CharField(max_length=63, null=True, blank=True)
+ editor = models.ForeignKey('self', models.CASCADE, null=True)
cla... | Self referencing foreign key doesn't correctly order by a relation "_id" field.
Description
Initially discovered on 2.2.10 but verified still happens on 3.0.6. Given the following models:
class OneModel(models.Model):
class Meta:
ordering = ("-id",)
id = models.BigAutoField(primary_key=True)
root = models.Foreig... | This is with a postgres backend. Fairly vanilla Django. Some generic middleware installed (cors, csrf, auth, session). Apps are: INSTALLED_APPS = ( "django.contrib.contenttypes", "django.contrib.auth", "django.contrib.admin", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "corsheade... | 2020-06-07T14:52:19Z | 3.2 | ["test_order_by_self_referential_fk (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_extra_ordering (ordering.tests.OrderingTests)", "test_extra_ordering_quoting (ordering.tests.OrderingTests)", "test_extra_ordering_with_table_nam... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d |
django__django-14411 | need to identify ReadOnlyPasswordHashWidget | 0 | django/contrib/auth/forms.py | django/django | fa4e963ee7e6876581b5432363603571839ba00c | 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
@@ -50,6 +50,9 @@ def get_context(self, name, value, attrs):
context['summary'] = summary
return context
+ def id_for_label(self, id_):
+ return No... | 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
@@ -13,6 +13,7 @@
from django.core import mail
from django.core.exceptions import ValidationError
from django.core.mail import EmailMultiAlternatives
+from django.for... | Label for ReadOnlyPasswordHashWidget points to non-labelable element.
Description
(last modified by David Sanders)
In the admin, the label element for the ReadOnlyPasswordHashWidget widget has a 'for' attribute which points to a non-labelable element, since the widget just renders text, not an input. There's no... | 2021-05-19T04:05:47Z | 4.0 | ["ReadOnlyPasswordHashWidget doesn't contain a for attribute in the"] | ["test_html_autocomplete_attributes (auth_tests.test_forms.AdminPasswordChangeFormTest)", "test_missing_passwords (auth_tests.test_forms.AdminPasswordChangeFormTest)", "test_non_matching_passwords (auth_tests.test_forms.AdminPasswordChangeFormTest)", "test_one_password (auth_tests.test_forms.AdminPasswordChangeFormTest... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | |
django__django-13447 | need to identify function _buil_app_dict. it is quite possible | 1 | django/contrib/admin/sites.py | django/django | 0456d3e42795481a186db05719300691fe2a1029 | diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -461,6 +461,7 @@ def _build_app_dict(self, request, label=None):
info = (app_label, model._meta.model_name)
model_dict = {
+ 'm... | diff --git a/tests/admin_views/test_adminsite.py b/tests/admin_views/test_adminsite.py
--- a/tests/admin_views/test_adminsite.py
+++ b/tests/admin_views/test_adminsite.py
@@ -55,7 +55,9 @@ def test_available_apps(self):
admin_views = apps[0]
self.assertEqual(admin_views['app_label'], 'admin_views')
... | Added model class to app_list context
Description
(last modified by Raffaele Salmaso)
I need to manipulate the app_list in my custom admin view, and the easiest way to get the result is to have access to the model class (currently the dictionary is a serialized model).
In addition I would make the _build_app_di... | 2020-09-22T08:49:25Z | 4.0 | ["test_available_apps (admin_views.test_adminsite.SiteEachContextTest)"] | ["test_add_action (admin_views.test_adminsite.SiteActionsTests)", "test_disable_action (admin_views.test_adminsite.SiteActionsTests)", "AdminSite.get_action() returns an action even if it's disabled.", "test_each_context (admin_views.test_adminsite.SiteEachContextTest)", "test_each_context_site_url_with_script_name (ad... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | |
django__django-12856 | check constraint and unique constraints are quite similar and it has given in the description implicitly otherwise difficult to find it | 1 | django/db/models/base.py | django/django | 8328811f048fed0dd22573224def8c65410c9f2e | 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
@@ -1926,6 +1926,12 @@ def _check_constraints(cls, databases):
id='models.W038',
)
)
+ fields = (
+ fiel... | 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
@@ -1501,3 +1501,70 @@ class Meta:
]
self.assertEqual(Model.check(databases=self.databases), [])
... | Add check for fields of UniqueConstraints.
Description
(last modified by Marnanel Thurman)
When a model gains a UniqueConstraint, makemigrations doesn't check that the fields named therein actually exist.
This is in contrast to the older unique_together syntax, which raises models.E012 if the fields don't exist... | Demonstration
Agreed. We can simply call cls._check_local_fields() for UniqueConstraint's fields. I attached tests.
Tests.
Hello Django Team, My name is Jannah Mandwee, and I am working on my final project for my undergraduate software engineering class (here is the link to the assignment: https://web.eecs.umich.edu/~... | 2020-05-04T21:29:23Z | 3.2 | ["test_unique_constraint_pointing_to_m2m_field (invalid_models_tests.test_models.ConstraintsTests)", "test_unique_constraint_pointing_to_missing_field (invalid_models_tests.test_models.ConstraintsTests)", "test_unique_constraint_pointing_to_non_local_field (invalid_models_tests.test_models.ConstraintsTests)"] | ["test_check_jsonfield (invalid_models_tests.test_models.JSONFieldTests)", "test_check_jsonfield_required_db_features (invalid_models_tests.test_models.JSONFieldTests)", "test_ordering_pointing_to_json_field_value (invalid_models_tests.test_models.JSONFieldTests)", "test_db_column_clash (invalid_models_tests.test_model... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d |
django__django-14787 | file structure is important | 0 | django/utils/decorators.py | django/django | 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 | |
django__django-11905 | only possibility with isnull but it has not followed exact capital sinple format in issue description | 0 | django/db/models/lookups.py | django/django | 2f72480fbd27896c986c45193e1603e35c0b19a7 | diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -1,5 +1,6 @@
import itertools
import math
+import warnings
from copy import copy
from django.core.exceptions import EmptyResultSet
@@ -9,6 +10,7 @@
)
from django.db.model... | diff --git a/tests/lookup/models.py b/tests/lookup/models.py
--- a/tests/lookup/models.py
+++ b/tests/lookup/models.py
@@ -96,3 +96,15 @@ class Product(models.Model):
class Stock(models.Model):
product = models.ForeignKey(Product, models.CASCADE)
qty_available = models.DecimalField(max_digits=6, decimal_plac... | Prevent using __isnull lookup with non-boolean value.
Description
(last modified by Mariusz Felisiak)
__isnull should not allow for non-boolean values. Using truthy/falsey doesn't promote INNER JOIN to an OUTER JOIN but works fine for a simple queries. Using non-boolean values is undocumented and untested. IMO... | PR here: https://github.com/django/django/pull/11873
After the reconsideration I don't think that we should change this documented behavior (that is in Django from the very beginning). __isnull lookup expects boolean values in many places and IMO it would be confusing if we'll allow for truthy/falsy values, e.g. take... | 2019-10-11T18:19:39Z | 3.1 | ["test_isnull_non_boolean_value (lookup.tests.LookupTests)", "test_iterator (lookup.tests.LookupTests)"] | ["test_chain_date_time_lookups (lookup.tests.LookupTests)", "test_count (lookup.tests.LookupTests)", "test_custom_field_none_rhs (lookup.tests.LookupTests)", "Lookup.can_use_none_as_rhs=True allows None as a lookup value.", "test_error_messages (lookup.tests.LookupTests)", "test_escaping (lookup.tests.LookupTests)", "t... | 0668164b4ac93a5be79f5b87fae83c657124d9ab |
django__django-15320 | Easy Just need to identift SUbquery class as the main issue | 0 | django/db/models/expressions.py | django/django | b55ebe32417e0884b6b8b3e1bc0379033aa221af | 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
@@ -1149,7 +1149,8 @@ class Subquery(BaseExpression, Combinable):
def __init__(self, queryset, output_field=None, **extra):
# Allow the usage of both... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -537,6 +537,15 @@ def test_subquery_eq(self):
qs.query.annotations['small_company'],
)
+ def test_subquery_sql(self):
+ employees = Employee.objects... | Subquery.as_sql() generates invalid SQL.
Description
(last modified by M1ha Shvn)
Since this commit Subquery.as_sql(...) method returns incorrect SQL removing first and last symbols instead of absent breakets. Adding Subquery().query.subquery = True attribute fixes the problem. From my point of view, it should... | Sounds reasonable.
Sounds reasonable to me as well, I'd only suggest we .clone() the query before altering though. | 2022-01-14T23:43:34Z | 4.1 | ["test_subquery_sql (expressions.tests.BasicExpressionsTests)"] | ["test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_equal_Value (expressions.tests.FTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTest... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 |
django__django-13230 | need to identify root cause as syndication.views | 0 | django/contrib/syndication/views.py | django/django | 184a6eebb0ef56d5f1b1315a8e666830e37f3f81 | diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py
--- a/django/contrib/syndication/views.py
+++ b/django/contrib/syndication/views.py
@@ -212,6 +212,7 @@ def get_feed(self, obj, request):
author_name=author_name,
author_email=author_email,
... | diff --git a/tests/syndication_tests/feeds.py b/tests/syndication_tests/feeds.py
--- a/tests/syndication_tests/feeds.py
+++ b/tests/syndication_tests/feeds.py
@@ -29,6 +29,9 @@ def item_pubdate(self, item):
def item_updateddate(self, item):
return item.updated
+ def item_comments(self, item):
+ ... | Add support for item_comments to syndication framework
Description
Add comments argument to feed.add_item() in syndication.views so that item_comments can be defined directly without having to take the detour via item_extra_kwargs .
Additionally, comments is already explicitly mentioned in the feedparser, but not imp... | 2020-07-23T14:59:50Z | 3.2 | ["test_rss2_feed (syndication_tests.tests.SyndicationFeedTest)"] | ["test_add_domain (syndication_tests.tests.SyndicationFeedTest)", "test_atom_feed (syndication_tests.tests.SyndicationFeedTest)", "test_atom_feed_published_and_updated_elements (syndication_tests.tests.SyndicationFeedTest)", "test_atom_multiple_enclosures (syndication_tests.tests.SyndicationFeedTest)", "test_atom_singl... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | |
django__django-11179 | root cause file | 0 | django/db/models/deletion.py | django/django | 19fc6376ce67d01ca37a91ef2f55ef769f50513a | diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -277,6 +277,7 @@ def delete(self):
if self.can_fast_delete(instance):
with transaction.mark_for_rollback_on_error():
count ... | diff --git a/tests/delete/tests.py b/tests/delete/tests.py
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -1,6 +1,7 @@
from math import ceil
from django.db import IntegrityError, connection, models
+from django.db.models.deletion import Collector
from django.db.models.sql.constants import GET_ITERATOR_... | delete() on instances of models without any dependencies doesn't clear PKs.
Description
Deleting any model with no dependencies not updates the PK on the model. It should be set to None after .delete() call.
See Django.db.models.deletion:276-281. Should update the model line 280.
| Reproduced at 1ffddfc233e2d5139cc6ec31a4ec6ef70b10f87f. Regression in bc7dd8490b882b2cefdc7faf431dc64c532b79c9. Thanks for the report.
Regression test.
I have attached a simple fix which mimics what https://github.com/django/django/blob/master/django/db/models/deletion.py#L324-L326 does for multiple objects. I am not ... | 2019-04-05T15:54:39Z | 3.0 | ["test_fast_delete_instance_set_pk_none (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_joined_qs (delete.tests.FastDeleteTests)", "test_fast_delete_large_batch (delete.tests.FastDeleteTest... | 419a78300f7cd27611196e1e464d50fd0385ff27 |
django__django-15781 | cant understand even for a human | 1 | django/core/management/base.py | django/django | 8d160f154f0240a423e83ffe0690e472f837373c | 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
@@ -286,10 +286,10 @@ def create_parser(self, prog_name, subcommand, **kwargs):
Create and return the ``ArgumentParser`` which will be used to
parse th... | diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -1,4 +1,5 @@
import os
+from argparse import ArgumentDefaultsHelpFormatter
from io import StringIO
from unittest import mock
@@ -408,8 +409,14 @@ def test_subparser_inva... | Customizable management command formatters.
Description
With code like:
class Command(BaseCommand):
help = '''
Import a contract from tzkt.
Example usage:
./manage.py tzkt_import 'Tezos Mainnet' KT1HTDtMBRCKoNHjfWEEvXneGQpCfPAt6BRe
'''
Help output is:
$ ./manage.py help tzkt_import
usage: manage.py tzkt_import ... | This seems no fault of Django but is rather the default behavior of ArgumentParser ("By default, ArgumentParser objects line-wrap the description and epilog texts in command-line help messages"). This can be changed by using a custom formatter_class, though Django already specifies a custom one (DjangoHelpFormatter)... | 2022-06-18T19:39:34Z | 4.2 | ["BaseCommand.create_parser() passes kwargs to CommandParser."] | ["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... | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 |
django__django-13710 | file structure name search need ti handle large code files as well | 0 | django/contrib/admin/options.py | django/django | 1bd6a7a0acc11e249fca11c017505ad39f15ebf6 | 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
@@ -2037,10 +2037,13 @@ def __init__(self, parent_model, admin_site):
self.opts = self.model._meta
self.has_registered_model = admin_site.is_regist... | diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
--- a/tests/admin_inlines/tests.py
+++ b/tests/admin_inlines/tests.py
@@ -967,6 +967,55 @@ def test_extra_inlines_are_not_shown(self):
class TestVerboseNameInlineForms(TestDataMixin, TestCase):
factory = RequestFactory()
+ def test_verb... | Use Admin Inline verbose_name as default for Inline verbose_name_plural
Description
Django allows specification of a verbose_name and a verbose_name_plural for Inline classes in admin views. However, verbose_name_plural for an Inline is not currently based on a specified verbose_name. Instead, it continues to be base... | Please push your patch as a Django pull request. | 2020-11-23T04:39:05Z | 4.0 | ["test_verbose_name_inline (admin_inlines.tests.TestVerboseNameInlineForms)"] | ["Regression for #9362", "test_deleting_inline_with_protected_delete_does_not_validate (admin_inlines.tests.TestInlineProtectedOnDelete)", "test_all_inline_media (admin_inlines.tests.TestInlineMedia)", "test_inline_media_only_base (admin_inlines.tests.TestInlineMedia)", "test_inline_media_only_inline (admin_inlines.tes... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 |
django__django-10924 | need to identify issue is wirh FilePathField and level iszero | 0 | django/db/models/fields/__init__.py | django/django | bceadd2788dc2dad53eba0caae172bd8522fd483 | 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
@@ -1709,7 +1709,7 @@ def get_prep_value(self, value):
def formfield(self, **kwargs):
return super().formfield(**{
- 'path... | diff --git a/tests/model_fields/test_filepathfield.py b/tests/model_fields/test_filepathfield.py
new file mode 100644
--- /dev/null
+++ b/tests/model_fields/test_filepathfield.py
@@ -0,0 +1,22 @@
+import os
+
+from django.db.models import FilePathField
+from django.test import SimpleTestCase
+
+
+class FilePathFieldTes... | Allow FilePathField path to accept a callable.
Description
I have a special case where I want to create a model containing the path to some local files on the server/dev machine. Seeing as the place where these files are stored is different on different machines I have the following:
import os
from django.conf import... | So, to clarify, what exactly is the bug/feature proposal/issue here? The way I see it, you're supposed to use os.path.join() and LOCAL_FILE_DIR to define a relative path. It's sort of like how we use BASE_DIR to define relative paths in a lot of other places. Could you please clarify a bit more as to what the issue is ... | 2019-02-03T11:30:12Z | 3.0 | ["test_callable_path (model_fields.test_filepathfield.FilePathFieldTests)"] | ["test_path (model_fields.test_filepathfield.FilePathFieldTests)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 |
django__django-13315 | need a trie | 0 | django/forms/models.py | django/django | 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 |
django__django-12708 | can identify rooot cause | 0 | django/db/backends/base/schema.py | django/django | 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 |
django__django-14730 | need to identify ManyToManyField | 0 | django/db/models/fields/related.py | django/django | 4fe3774c729f3fd5105b3001fe69a70bdca95ac3 | 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
@@ -1258,6 +1258,16 @@ def _check_ignored_options(self, **kwargs):
)
)
+ if self.remote_field.symmetrical and self... | diff --git a/tests/field_deconstruction/tests.py b/tests/field_deconstruction/tests.py
--- a/tests/field_deconstruction/tests.py
+++ b/tests/field_deconstruction/tests.py
@@ -438,7 +438,6 @@ class MyModel(models.Model):
m2m = models.ManyToManyField('self')
m2m_related_name = models.ManyToManyF... | Prevent developers from defining a related_name on symmetrical ManyToManyFields
Description
In ManyToManyField, if the symmetrical argument is passed, or if it's a self-referential ManyToMany relationship, the related field on the target model is not created. However, if a developer passes in the related_name not und... | I have a PR that implements this incoming.
https://github.com/django/django/pull/14730
OK, I guess we can do something here — it probably is a source of confusion. The same issue was raised in #18021 (but as an invalid bug report, rather than suggesting improving the messaging). Looking at the PR — I'm sceptical about... | 2021-08-03T04:27:52Z | 4.0 | ["test_many_to_many_with_useless_related_name (invalid_models_tests.test_relative_fields.RelativeFieldTests)"] | ["test_accessor_clash (invalid_models_tests.test_relative_fields.SelfReferentialFKClashTests)", "test_clash_under_explicit_related_name (invalid_models_tests.test_relative_fields.SelfReferentialFKClashTests)", "test_reverse_query_name_clash (invalid_models_tests.test_relative_fields.SelfReferentialFKClashTests)", "test... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 |
django__django-13551 | easy after identifying _make_hash_value | 0 | django/contrib/auth/tokens.py | django/django | 7f9e4524d6b23424cf44fbe1bf1f4e70f6bb066e | diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
--- a/django/contrib/auth/tokens.py
+++ b/django/contrib/auth/tokens.py
@@ -78,9 +78,9 @@ def _make_token_with_timestamp(self, user, timestamp, legacy=False):
def _make_hash_value(self, user, timestamp):
"""
- Hash the use... | diff --git a/tests/auth_tests/models/__init__.py b/tests/auth_tests/models/__init__.py
--- a/tests/auth_tests/models/__init__.py
+++ b/tests/auth_tests/models/__init__.py
@@ -8,6 +8,7 @@
from .no_password import NoPasswordUser
from .proxy import Proxy, UserProxy
from .uuid_pk import UUIDUser
+from .with_custom_email... | Changing user's email could invalidate password reset tokens
Description
Sequence:
Have account with email address foo@…
Password reset request for that email (unused)
foo@… account changes their email address
Password reset email is used
The password reset email's token should be rejected at that point, but in fact ... | 2020-10-17T17:22:01Z | 3.2 | ["Updating the user email address invalidates the token.", "test_token_with_different_secret (auth_tests.test_tokens.TokenGeneratorTest)"] | ["test_str (auth_tests.test_models.GroupTests)", "test_group_natural_key (auth_tests.test_models.NaturalKeysTestCase)", "test_user_natural_key (auth_tests.test_models.NaturalKeysTestCase)", "test_check_password (auth_tests.test_models.AnonymousUserTests)", "test_delete (auth_tests.test_models.AnonymousUserTests)", "tes... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | |
django__django-13933 | easy after identifying ModelMultipleChoiceField | 1 | django/forms/models.py | django/django | 42e8cf47c7ee2db238bf91197ea398126c546741 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -1284,7 +1284,11 @@ def to_python(self, value):
value = getattr(value, key)
value = self.queryset.get(**{key: value})
except (ValueError, TypeError, self.query... | diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py
--- a/tests/forms_tests/tests/test_error_messages.py
+++ b/tests/forms_tests/tests/test_error_messages.py
@@ -308,3 +308,16 @@ def test_modelchoicefield(self):
self.assertFormErrors(['REQUIRED'], f.clea... | ModelChoiceField does not provide value of invalid choice when raising ValidationError
Description
(last modified by Aaron Wiegel)
Compared with ChoiceField and others, ModelChoiceField does not show the value of the invalid choice when raising a validation error. Passing in parameters with the invalid value an... | This message has been the same literally forever b2b6fc8e3c78671c8b6af2709358c3213c84d119. Given that ChoiceField passes the value when raising the error, if you set error_messages you should be able to get the result you want.
Replying to Carlton Gibson: This message has been the same literally forever b2b6fc8e3c786... | 2021-01-26T03:58:23Z | 4.0 | ["test_modelchoicefield_value_placeholder (forms_tests.tests.test_error_messages.ModelChoiceFieldErrorMessagesTestCase)"] | ["test_modelchoicefield (forms_tests.tests.test_error_messages.ModelChoiceFieldErrorMessagesTestCase)", "test_booleanfield (forms_tests.tests.test_error_messages.FormsErrorMessagesTestCase)", "test_charfield (forms_tests.tests.test_error_messages.FormsErrorMessagesTestCase)", "test_choicefield (forms_tests.tests.test_e... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 |
django__django-13660 | easy with tsacktrace | 0 | django/core/management/commands/shell.py | django/django | 50c3ac6fa9b7c8a94a6d1dc87edf775e3bc4d575 | diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
--- a/django/core/management/commands/shell.py
+++ b/django/core/management/commands/shell.py
@@ -84,13 +84,13 @@ def python(self, options):
def handle(self, **options):
# Execute the command and exit.
... | diff --git a/tests/shell/tests.py b/tests/shell/tests.py
--- a/tests/shell/tests.py
+++ b/tests/shell/tests.py
@@ -9,6 +9,13 @@
class ShellCommandTestCase(SimpleTestCase):
+ script_globals = 'print("__name__" in globals())'
+ script_with_inline_function = (
+ 'import django\n'
+ 'def f():\n'
+ ... | shell command crashes when passing (with -c) the python code with functions.
Description
The examples below use Python 3.7 and Django 2.2.16, but I checked that the code is the same on master and works the same in Python 3.8.
Here's how python -c works:
$ python -c <<EOF "
import django
def f():
print(django.__ve... | PR includes tests and documents the new feature in the release notes (but not in the main docs since it seems more like a bug fix than a new feature to me). | 2020-11-09T22:43:32Z | 3.2 | ["test_command_option_inline_function_call (shell.tests.ShellCommandTestCase)", "test_stdin_read_inline_function_call (shell.tests.ShellCommandTestCase)"] | ["test_command_option (shell.tests.ShellCommandTestCase)", "test_command_option_globals (shell.tests.ShellCommandTestCase)", "test_shell_with_bpython_not_installed (shell.tests.ShellCommandTestCase)", "test_shell_with_ipython_not_installed (shell.tests.ShellCommandTestCase)", "test_stdin_read (shell.tests.ShellCommandT... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d |
django__django-16527 | easy | 0 | django/contrib/admin/templatetags/admin_modify.py | django/django | 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 |
django__django-12589 | file structure will help | 0 | django/db/models/sql/query.py | django/django | 895f28f9cbed817c00ab68770433170d83132d90 | 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
@@ -1927,6 +1927,19 @@ def set_group_by(self, allow_aliases=True):
primary key, and the query would be equivalent, the optimization
will be made automatica... | diff --git a/tests/aggregation/models.py b/tests/aggregation/models.py
--- a/tests/aggregation/models.py
+++ b/tests/aggregation/models.py
@@ -5,6 +5,7 @@ class Author(models.Model):
name = models.CharField(max_length=100)
age = models.IntegerField()
friends = models.ManyToManyField('self', blank=True)
+... | Django 3.0: "GROUP BY" clauses error with tricky field annotation
Description
Let's pretend that we have next model structure with next model's relations:
class A(models.Model):
bs = models.ManyToManyField('B',
related_name="a",
through="AB")
class B(models.Model):
pass
class AB(models.Model):
a = ... | This is due to a collision of AB.status and the status annotation. The easiest way to solve this issue is to disable group by alias when a collision is detected with involved table columns. This can be easily worked around by avoiding to use an annotation name that conflicts with involved table column names.
@Simon I t... | 2020-03-19T19:04:17Z | 3.1 | ["test_aggregation_subquery_annotation_values_collision (aggregation.tests.AggregateTestCase)"] | ["test_add_implementation (aggregation.tests.AggregateTestCase)", "test_aggregate_alias (aggregation.tests.AggregateTestCase)", "test_aggregate_annotation (aggregation.tests.AggregateTestCase)", "test_aggregate_in_order_by (aggregation.tests.AggregateTestCase)", "test_aggregate_multi_join (aggregation.tests.AggregateTe... | 0668164b4ac93a5be79f5b87fae83c657124d9ab |
django__django-12700 | easy | 0 | django/views/debug.py | django/django | d51c50d836c5cf8db5566da17963f871be554615 | diff --git a/django/views/debug.py b/django/views/debug.py
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -90,6 +90,10 @@ def cleanse_setting(self, key, value):
cleansed = self.cleansed_substitute
elif isinstance(value, dict):
cleansed = {k: self.cleanse_settin... | diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -1249,6 +1249,41 @@ def test_cleanse_setting_recurses_in_dictionary(self):
{'login': 'cooper', 'password': reporter_filter.cleans... | Settings are cleaned insufficiently.
Description
Posting publicly after checking with the rest of the security team.
I just ran into a case where django.views.debug.SafeExceptionReporterFilter.get_safe_settings() would return several un-cleansed values. Looking at cleanse_setting() I realized that we only take care ... | Do I need to change both versions? Or just create a single implementation for current master branch? | 2020-04-11T01:58:27Z | 3.1 | ["test_cleanse_setting_recurses_in_list_tuples (view_tests.tests.test_debug.ExceptionReporterFilterTests)"] | ["test_repr (view_tests.tests.test_debug.CallableSettingWrapperTests)", "test_sensitive_post_parameters_not_called (view_tests.tests.test_debug.DecoratorsTests)", "test_sensitive_variables_not_called (view_tests.tests.test_debug.DecoratorsTests)", "test_cleansed_substitute_override (view_tests.tests.test_debug.CustomEx... | 0668164b4ac93a5be79f5b87fae83c657124d9ab |
django__django-11039 | need to identify issue is with sqlmigrate | 0 | django/core/management/commands/sqlmigrate.py | django/django | d5276398046ce4a102776a1e67dcac2884d80dfe | diff --git a/django/core/management/commands/sqlmigrate.py b/django/core/management/commands/sqlmigrate.py
--- a/django/core/management/commands/sqlmigrate.py
+++ b/django/core/management/commands/sqlmigrate.py
@@ -55,8 +55,9 @@ def handle(self, *args, **options):
migration_name, app_label))
t... | 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
@@ -536,7 +536,13 @@ def test_sqlmigrate_forwards(self):
index_op_desc_unique_together = output.find('-- alter unique_together')
index_tx_e... | sqlmigrate wraps it's outpout in BEGIN/COMMIT even if the database doesn't support transactional DDL
Description
(last modified by Simon Charette)
The migration executor only adds the outer BEGIN/COMMIT if the migration is atomic and the schema editor can rollback DDL but the current sqlmigrate logic only tak... | I marked the ticket as easy picking because I included the above guidelines but feel free to uncheck it if you deem it inappropriate. Super. We don't have enough Easy Pickings tickets for the demand, so this kind of thing is great. (IMO 🙂)
Hey, I'm working on this ticket, I would like you to know as this is my first t... | 2019-03-01T10:24:38Z | 3.0 | ["test_sqlmigrate_for_non_transactional_databases (migrations.test_commands.MigrateTests)"] | ["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... | 419a78300f7cd27611196e1e464d50fd0385ff27 |
django__django-15498 | difficult but docstring is really helpfu to get that | 2 | django/views/static.py | django/django | d90e34c61b27fba2527834806639eebbcfab9631 | diff --git a/django/views/static.py b/django/views/static.py
--- a/django/views/static.py
+++ b/django/views/static.py
@@ -129,12 +129,14 @@ def was_modified_since(header=None, mtime=0, size=0):
if header is None:
raise ValueError
matches = re.match(r"^([^;]+)(; length=([0-9]+))?$", heade... | diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py
--- a/tests/view_tests/tests/test_static.py
+++ b/tests/view_tests/tests/test_static.py
@@ -191,3 +191,6 @@ def test_was_modified_since_fp(self):
mtime = 1343416141.107817
header = http_date(mtime)
self... | Fix handling empty string for If-Modified-Since header
Description
Empty string used to be ignored for If-Modified-Since header, but now raises exception since d6aff369ad3.
Fix handling empty string for If-Modified-Since header
Description
Empty string used to be ignored for If-Modified-Since header, but now raises... | 2022-03-10T19:47:15Z | 4.1 | ["test_was_modified_since_empty_string (view_tests.tests.test_static.StaticUtilsTests)"] | ["A floating point mtime does not disturb was_modified_since (#18675).", "test_404 (view_tests.tests.test_static.StaticHelperTest)", "The static view should stream files in chunks to avoid large memory usage", "test_copes_with_empty_path_component (view_tests.tests.test_static.StaticHelperTest)", "No URLs are served if... | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | |
django__django-14999 | easy after determining root issue as renamemodel | 0 | django/db/migrations/operations/models.py | django/django | 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 | |
django__django-14534 | need to identify id_for_label | 0 | django/forms/boundfield.py | django/django | 910ecd1b8df7678f45c3d507dde6bcb1faafa243 | diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -277,7 +277,7 @@ def template_name(self):
@property
def id_for_label(self):
- return 'id_%s_%s' % (self.data['name'], self.data['index'])
+ return self.data... | diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -720,7 +720,7 @@ class BeatleForm(Form):
fields = list(BeatleForm(auto_id=False)['name'])
self.assertEqual(len(fields), ... | BoundWidget.id_for_label ignores id set by ChoiceWidget.options
Description
If you look at the implementation of BoundField.subwidgets
class BoundField:
...
def subwidgets(self):
id_ = self.field.widget.attrs.get('id') or self.auto_id
attrs = {'id': id_} if id_ else {}
attrs = self.build_widget_attrs(attrs)
... | Hey Jacob — Sounds right: I didn't look in-depth but, if you can put your example in a test case it will be clear enough in the PR. Thanks.
Thanks Carlton, I will create a pull request asap.
Here is a pull request fixing this bug: https://github.com/django/django/pull/14533 (closed without merging)
Here is the new pul... | 2021-06-17T15:37:34Z | 4.0 | ["If auto_id is provided when initializing the form, the generated ID in", "test_iterable_boundfield_select (forms_tests.tests.test_forms.FormsTestCase)"] | ["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for... | 475cffd1d64c690cdad16ede4d5e81985738ceb4 |
django__django-14238 | need to identify bigautofields | 0 | django/db/models/fields/__init__.py | django/django | 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 | |
django__django-11742 | need to identify Field as the root | 0 | django/db/models/fields/__init__.py | django/django | fee75d2aed4e58ada6567c464cfd22e89dc65f4a | 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
@@ -257,6 +257,7 @@ def is_value(value, accept_promise=True):
)
]
+ choice_max_length = 0
# Expect [g... | diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py
--- a/tests/invalid_models_tests/test_ordinary_fields.py
+++ b/tests/invalid_models_tests/test_ordinary_fields.py
@@ -304,6 +304,32 @@ class Model(models.Model):
self.assertEqual(Model._meta.g... | Add check to ensure max_length fits longest choice.
Description
There is currently no check to ensure that Field.max_length is large enough to fit the longest value in Field.choices.
This would be very helpful as often this mistake is not noticed until an attempt is made to save a record with those values that are to... | 2019-09-04T08:30:14Z | 3.0 | ["test_choices_in_max_length (invalid_models_tests.test_ordinary_fields.CharFieldTests)", "test_choices_named_group (invalid_models_tests.test_ordinary_fields.CharFieldTests)"] | ["test_non_nullable_blank (invalid_models_tests.test_ordinary_fields.GenericIPAddressFieldTests)", "test_forbidden_files_and_folders (invalid_models_tests.test_ordinary_fields.FilePathFieldTests)", "test_max_length_warning (invalid_models_tests.test_ordinary_fields.IntegerFieldTests)", "test_primary_key (invalid_models... | 419a78300f7cd27611196e1e464d50fd0385ff27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.