repo
stringclasses
1 value
instance_id
stringlengths
20
20
base_commit
stringlengths
40
40
patch
stringlengths
386
5.2k
test_patch
stringlengths
478
4.45k
problem_statement
stringlengths
190
8.54k
hints_text
stringlengths
0
9.06k
created_at
stringdate
2021-05-04 20:10:27
2022-04-08 06:55:17
version
stringclasses
2 values
FAIL_TO_PASS
stringlengths
52
15.4k
PASS_TO_PASS
stringlengths
2
28.5k
environment_setup_commit
stringclasses
2 values
difficulty
stringclasses
3 values
django/django
django__django-14349
a708f39ce67af174df90c5b5e50ad1976cec7cb8
diff --git a/django/core/validators.py b/django/core/validators.py --- a/django/core/validators.py +++ b/django/core/validators.py @@ -92,6 +92,7 @@ class URLValidator(RegexValidator): r'\Z', re.IGNORECASE) message = _('Enter a valid URL.') schemes = ['http', 'https', 'ftp', 'ftps'] + unsafe_chars...
diff --git a/tests/validators/tests.py b/tests/validators/tests.py --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -226,9 +226,15 @@ (URLValidator(), None, ValidationError), (URLValidator(), 56, ValidationError), (URLValidator(), 'no_scheme', ValidationError), - # Trailing newlines ...
URLValidator tests failing on Python versions patched for bpo-43882 Description On Python versions with a fix for ​bpo-43882 (i.e. 3.10.0b1 and the 3.9 git branch, not released yet) the following tests fail: ====================================================================== FAIL: test_validators (validators.tests...
Thanks for the report. We noticed this issue. Duplicate of #32074. For the record, I was wrong that this hasn't been released in 3.9 -- it's part of 3.9.5. It looks that it will be backported to all supported versions of Python.
2021-05-04T20:10:27Z
4.0
["test_validators (validators.tests.TestValidators)"]
["test_domain_whitelist (validators.tests.DeprecationTests)", "test_domain_whitelist_access_warning (validators.tests.DeprecationTests)", "test_domain_whitelist_set_warning (validators.tests.DeprecationTests)", "test_whitelist (validators.tests.DeprecationTests)", "test_whitelist_warning (validators.tests.DeprecationTe...
475cffd1d64c690cdad16ede4d5e81985738ceb4
15 min - 1 hour
django/django
django__django-14351
06fd4df41afb5aa1d681b853c3c08d8c688ca3a5
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py --- a/django/db/models/lookups.py +++ b/django/db/models/lookups.py @@ -406,6 +406,15 @@ def process_rhs(self, compiler, connection): self.rhs.add_fields(['pk']) return super().process_rhs(compiler, connection) + d...
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -1525,6 +1525,14 @@ class DistinctAggregate(Aggregate): allow_distinct = True DistinctAggregate('foo', distinct=True) + @sk...
Q object __or__ appears to get all dunder related's default columns and queryset raises ProgrammingError. Description There appears to be a difference in how Q object aliases are setup, when OR'd. The get_default_columns for this agent__property_groups__id__in only uses 1, where as get_default_columns for this agent_...
Thanks for the report. Can you provide a sample project? (models definition and a complete queryset). I cannot reproduce this issue with provided details. Replying to Mariusz Felisiak: Thanks for the report. Can you provide a sample project? (models definition and a complete queryset). I cannot reproduce this issue wit...
2021-05-05T03:50:44Z
4.0
["test_having_subquery_select (aggregation_regress.tests.AggregationTests)"]
["test_ticket_24748 (aggregation_regress.tests.SelfReferentialFKTests)", "test_existing_join_not_promoted (aggregation_regress.tests.JoinPromotionTests)", "test_non_nullable_fk_not_promoted (aggregation_regress.tests.JoinPromotionTests)", "test_ticket_21150 (aggregation_regress.tests.JoinPromotionTests)", "test_aggrega...
475cffd1d64c690cdad16ede4d5e81985738ceb4
15 min - 1 hour
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-14404
de32fe83a2e4a20887972c69a0693b94eb25a88b
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -420,14 +420,13 @@ def autocomplete_view(self, request): def catch_all_view(self, request, url): if settings.APPEND_SLASH and not url.endswith('/'): ...
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -6602,6 +6602,42 @@ def test_missing_slash_append_slash_true(self): response = self.client.get(known_url[:-1]) self.assertRedirects(response, known_url, status_code...
catch_all_view() does not support FORCE_SCRIPT_NAME. Description (last modified by SlavaSkvortsov) catch_all_view returns redirect to '%s/' % request.path_info (script name cut off there) instead of '%s/' % request.path (with the script name) Patch - ​https://github.com/django/django/pull/14404
2021-05-17T11:24:06Z
4.0
["test_missing_slash_append_slash_true_force_script_name (admin_views.tests.AdminSiteFinalCatchAllPatternTests)", "test_missing_slash_append_slash_true_script_name (admin_views.tests.AdminSiteFinalCatchAllPatternTests)"]
["test_explicitly_provided_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_implicitly_generated_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_should_be_able_to_edit_related_objects_on_add_view (admin_views.tests.AdminCustomSaveRelatedTests)", "test_should_be_able_to_edit_related_ob...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<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-14493
7272e1963ffdf39c1d4fe225d5425a45dd095d11
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py --- a/django/contrib/staticfiles/storage.py +++ b/django/contrib/staticfiles/storage.py @@ -260,6 +260,7 @@ def post_process(self, paths, dry_run=False, **options): processed_adjustable_paths[name] = (name, hashe...
diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py --- a/tests/staticfiles_tests/storage.py +++ b/tests/staticfiles_tests/storage.py @@ -97,3 +97,7 @@ class ExtraPatternsStorage(ManifestStaticFilesStorage): class NoneHashStorage(ManifestStaticFilesStorage): def file_hash(self, na...
ManifestStaticFilesStorage crashes with max_post_process_passes = 0. Description To reproduce: Derive a custom class from ManifestStaticFilesStorage and set max_post_process_passes to 0: class MyManifestStaticFilesStorage(ManifestStaticFilesStorage): max_post_process_passes = 0 # settings.py STATICFILES_STORAGE = "M...
An effective workaround is overriding patterns = (). It might not be worth fixing the UnboundLocalError. I think it's worth fixing. Hi guys, Can I work on this? Replying to kingliar420: Can I work on this? Sure there is no need to ask. Please remember that a regression test is required.
2021-06-05T12:50:25Z
4.0
["test_collectstatistic_no_post_process_replaced_paths (staticfiles_tests.test_storage.TestCollectionNoPostProcessReplacedPaths)"]
["test_hashed_name (staticfiles_tests.test_storage.TestCollectionNoneHashStorage)", "With storage classes having several file extension patterns, only the", "test_collect_static_files_default_permissions (staticfiles_tests.test_storage.TestStaticFilePermissions)", "test_collect_static_files_permissions (staticfiles_tes...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
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-14534
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
<15 min fix
django/django
django__django-14539
6a5ef557f80a8eb6a758ebe99c8bb477ca47459e
diff --git a/django/utils/html.py b/django/utils/html.py --- a/django/utils/html.py +++ b/django/utils/html.py @@ -283,8 +283,9 @@ def trim_punctuation(lead, middle, trail): middle_unescaped = html.unescape(middle) stripped = middle_unescaped.rstrip(TRAILING_PUNCTUATION_CHARS) if ...
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py --- a/tests/utils_tests/test_html.py +++ b/tests/utils_tests/test_html.py @@ -250,6 +250,10 @@ def test_urlize(self): 'Search for google.com/?q=! and see.', 'Search for <a href="http://google.com/?q=">google.c...
urlize() does not handle html escaped string and trailing punctuation correctly Description Example: urlize('Search for google.com/?q=1&lt! and see.') # expected output 'Search for <a href="http://google.com/?q=1%3C">google.com/?q=1&lt</a>! and see.' # actual output 'Search for <a href="http://google.com/?q=1%3C">goo...
​https://github.com/django/django/pull/14539/ OK, thanks, the example looks right. It's always delicate but let's take this for review. Related to #26193.
2021-06-19T11:31:16Z
4.0
["test_urlize (utils_tests.test_html.TestUtilsHtml)", "test_urlize_unchanged_inputs (utils_tests.test_html.TestUtilsHtml)"]
["test_conditional_escape (utils_tests.test_html.TestUtilsHtml)", "test_escape (utils_tests.test_html.TestUtilsHtml)", "test_escapejs (utils_tests.test_html.TestUtilsHtml)", "test_format_html (utils_tests.test_html.TestUtilsHtml)", "test_html_safe (utils_tests.test_html.TestUtilsHtml)", "test_html_safe_defines_html_err...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
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-14580
36fa071d6ebd18a61c4d7f1b5c9d17106134bd44
diff --git a/django/db/migrations/serializer.py b/django/db/migrations/serializer.py --- a/django/db/migrations/serializer.py +++ b/django/db/migrations/serializer.py @@ -273,7 +273,7 @@ def _format(self): class TypeSerializer(BaseSerializer): def serialize(self): special_cases = [ - (models.M...
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -658,6 +658,13 @@ def test_serialize_functools_partialmethod(self): def test_serialize_type_none(self): self.assertSerializedEqual(type(None)) + ...
Missing import statement in generated migration (NameError: name 'models' is not defined) Description I found a bug in Django's latest release: 3.2.4. Given the following contents of models.py: from django.db import models class MyField(models.TextField): pass class MyBaseModel(models.Model): class Meta: abstrac...
I could reproduce the issue with 3.2.4, 2.2.24 and the main branch. For what it's worth, the issue doesn't occur if the class MyModel does inherit from MyMixin. MyBaseModel is not necessary to reproduce this issue, it's due to the fact that MyModel doesn't have fields from django.db.models and has custom bases. It look...
2021-07-01T07:38:03Z
4.0
["test_serialize_type_model (migrations.test_writer.WriterTests)"]
["test_args_kwargs_signature (migrations.test_writer.OperationWriterTests)", "test_args_signature (migrations.test_writer.OperationWriterTests)", "test_empty_signature (migrations.test_writer.OperationWriterTests)", "test_expand_args_signature (migrations.test_writer.OperationWriterTests)", "test_kwargs_signature (migr...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
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-14631
84400d2e9db7c51fee4e9bb04c028f665b8e7624
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -1,6 +1,7 @@ import datetime import re +from django.core.exceptions import ValidationError from django.forms.utils import flatatt, pretty_name from django.forms.widgets import ...
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -2112,15 +2112,47 @@ class DateTimeForm(Form): self.assertEqual(unbound['hi_without_microsec'].value(), now_no_ms) self....
BaseForm's _clean_fields() and changed_data should access values via BoundField Description (last modified by Chris Jerdonek) While working on #32917, I noticed that ​BaseForm._clean_fields() and ​BaseForm.changed_data don't currently access their values through a BoundField object. It would be better for consi...
Here is how to make the failing test I mentioned above (roughly): def test_datetime_clean_initial_callable_disabled(self): - now = datetime.datetime(2006, 10, 25, 14, 30, 45, 123456) - class DateTimeForm(forms.Form): - dt = DateTimeField(initial=lambda: now, disabled=True) + dt = DateTimeField(initial=datetime.datetime...
2021-07-13T09:16:48Z
4.0
["The cleaned value for a form with a disabled DateTimeField and callable", "Cleaning a form with a disabled DateTimeField and callable initial"]
["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for...
475cffd1d64c690cdad16ede4d5e81985738ceb4
1-4 hours
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-14752
b64db05b9cedd96905d637a2d824cbbf428e40e7
diff --git a/django/contrib/admin/views/autocomplete.py b/django/contrib/admin/views/autocomplete.py --- a/django/contrib/admin/views/autocomplete.py +++ b/django/contrib/admin/views/autocomplete.py @@ -11,7 +11,8 @@ class AutocompleteJsonView(BaseListView): def get(self, request, *args, **kwargs): """ ...
diff --git a/tests/admin_views/test_autocomplete_view.py b/tests/admin_views/test_autocomplete_view.py --- a/tests/admin_views/test_autocomplete_view.py +++ b/tests/admin_views/test_autocomplete_view.py @@ -1,3 +1,4 @@ +import datetime import json from contextlib import contextmanager @@ -293,6 +294,29 @@ class PKO...
Refactor AutocompleteJsonView to support extra fields in autocomplete response Description (last modified by mrts) Adding data attributes to items in ordinary non-autocomplete foreign key fields that use forms.widgets.Select-based widgets is relatively easy. This enables powerful and dynamic admin site customiz...
Makes sense to me.
2021-08-07T16:34:32Z
4.0
["test_serialize_result (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)"]
["test_custom_to_field (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_custom_to_field_custom_pk (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_custom_to_field_permission_denied (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_field_does_not_allowed (...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
django/django
django__django-14765
4e8121e8e42a24acc3565851c9ef50ca8322b15c
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -91,10 +91,11 @@ class ProjectState: def __init__(self, models=None, real_apps=None): self.models = models or {} # Apps to include from main regist...
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -924,6 +924,10 @@ class Meta: 1, ) + def test_real_apps_non_set(self): + with self.assertRaises(AssertionError): + Projec...
ProjectState.__init__() can assume its real_apps argument is a set Description ​PR #14760 made all calls to ProjectState.__init__() pass real_apps as a set. In ​ProjectState.__init__() now, then, instead of checking that real_apps is a set and converting it to a set if not, it can just assert that it's a set when non...
Hey Chris. I'm a bit Meh about the suggestion here but I'll accept so you can make the PR for review. (If the others like it...) ...part of Django's internal API I'm forever amazed what parts of Django folks out there are using. Perhaps not this. :) Thanks.
2021-08-12T05:59:11Z
4.0
["test_real_apps_non_set (migrations.test_state.StateTests)"]
["test_abstract_model_children_inherit_indexes (migrations.test_state.ModelStateTests)", "test_bound_field_sanity_check (migrations.test_state.ModelStateTests)", "Tests making a ProjectState from an Apps with a swappable model", "A swappable model inheriting from a hierarchy:", "Tests making a ProjectState from unused ...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
django/django
django__django-14771
4884a87e022056eda10534c13d74e49b8cdda632
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -220,6 +220,11 @@ def get_child_arguments(): py_script = Path(sys.argv[0]) args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + if sys.implementation.name...
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py --- a/tests/utils_tests/test_autoreload.py +++ b/tests/utils_tests/test_autoreload.py @@ -170,6 +170,7 @@ class TestChildArguments(SimpleTestCase): @mock.patch.dict(sys.modules, {'__main__': django.__main__}) @mock.patch(...
Auto-reloader should pass -X options (for cpython implementation) Description Windows OS $ winpty python -m django startproject my_project $ cd my_project/ $ winpty python -m django startapp my_app $ vi my_app/apps.py # demo for xoptions ... $ cat -n my_app/apps.py 1 from django.apps import AppConfig 2 3 class ...
2021-08-15T07:26:17Z
4.1
["test_xoptions (utils_tests.test_autoreload.TestChildArguments)"]
["test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_ex...
647480166bfe7532e8c471fef0146e3a17e6c0c9
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-14792
d89f976bddb49fb168334960acc8979c3de991fa
diff --git a/django/utils/timezone.py b/django/utils/timezone.py --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -72,8 +72,11 @@ def get_current_timezone_name(): def _get_timezone_name(timezone): - """Return the name of ``timezone``.""" - return str(timezone) + """ + Return the offset ...
diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py --- a/tests/utils_tests/test_timezone.py +++ b/tests/utils_tests/test_timezone.py @@ -260,6 +260,31 @@ def test_make_aware_zoneinfo_non_existent(self): self.assertEqual(std.utcoffset(), datetime.timedelta(hours=1)) se...
Reverse time zone conversion in Trunc()/Extract() database functions. Description When using a time zone of "Etc/GMT-10" (or similar) for a Trunc class tzinfo, it appears there's a different behavior as of Django 3.2 in the resulting database query. I think it's due to a change in the return value of timezone._get_ti...
Thanks for the report. Regression in 10d126198434810529e0220b0c6896ed64ca0e88. Reproduced at 4fe3774c729f3fd5105b3001fe69a70bdca95ac3. This problem is also affecting MySQL, the timezone "Etc/GMT-10" is returning "-10" instead of "-10:00". #33037
2021-08-24T09:25:15Z
4.0
["The _get_timezone_name() helper must return the offset for fixed offset", "test_is_aware (utils_tests.test_timezone.TimezoneTests)"]
["test_activate_invalid_timezone (utils_tests.test_timezone.TimezoneTests)", "test_fixedoffset_negative_timedelta (utils_tests.test_timezone.TimezoneTests)", "test_fixedoffset_timedelta (utils_tests.test_timezone.TimezoneTests)", "test_get_default_timezone (utils_tests.test_timezone.TimezoneTests)", "test_get_default_t...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
django/django
django__django-14855
475cffd1d64c690cdad16ede4d5e81985738ceb4
diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -209,7 +209,11 @@ def get_admin_url(self, remote_field, remote_obj): remote_field.model._meta.model_name, ) try: - url =...
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py --- a/tests/admin_views/admin.py +++ b/tests/admin_views/admin.py @@ -1142,6 +1142,8 @@ def get_formsets_with_inlines(self, request, obj=None): raw_id_fields=['parent'], ) site2.register(Person, save_as_continue=False) +site2.register(ReadOnlyR...
Wrong URL generated by get_admin_url for readonly field in custom Admin Site Description When a model containing a ForeignKey field is viewed (or edited) in a custom Admin Site, and that ForeignKey field is listed in readonly_fields, the url generated for the link is /admin/... instead of /custom-admin/.... This appe...
Hey Ken, yes seems right. Good spot. Looks like this should have been part of b79088306513d5ed76d31ac40ab3c15f858946ea for #31181 (which was Django 3.2) ​here. However, I don't know if there are any side effects and I have not yet run the full suite of tests on this. Mostly looking for feedback whether I'm on the right...
2021-09-14T01:27:01Z
4.0
["test_readonly_foreignkey_links_custom_admin_site (admin_views.tests.ReadonlyTest)"]
["test_explicitly_provided_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_implicitly_generated_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_should_be_able_to_edit_related_objects_on_add_view (admin_views.tests.AdminCustomSaveRelatedTests)", "test_should_be_able_to_edit_related_ob...
475cffd1d64c690cdad16ede4d5e81985738ceb4
<15 min fix
django/django
django__django-14915
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
<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-15022
e1d673c373a7d032060872b690a92fc95496612e
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1031,6 +1031,7 @@ def construct_search(field_name): if search_fields and search_term: orm_lookups = [construct_search(str(search_field)) ...
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py --- a/tests/admin_changelist/admin.py +++ b/tests/admin_changelist/admin.py @@ -36,6 +36,12 @@ class ParentAdmin(admin.ModelAdmin): list_select_related = ['child'] +class ParentAdminTwoSearchFields(admin.ModelAdmin): + list_filte...
Unnecessary joins in admin changelist query Description Django 1.2.5 Models: class Client(models.Model): name = models.CharField(_('name'), max_length=256) name2 = models.CharField(_('unofficial or obsolete name'), max_length=256, blank=True, null=True) contact_person = models.CharField(_('contact person'), max_le...
patch has been made from Mercurial repository This seems related to #13902 and #15819. Are you able to test if this gets fixed by using Django 1.3 or trunk? Looking at the code, the part that is modified by the patch is not modified in current trunk. The problematic pattern is still there: for bit in self.query.split()...
2021-10-24T17:48:28Z
4.1
["test_many_search_terms (admin_changelist.tests.ChangeListTests)", "All rows containing each of the searched words are returned, where each", "Searches over multi-valued relationships return rows from related"]
["{% get_admin_log %} works if the user model's primary key isn't named", "test_missing_args (admin_changelist.tests.GetAdminLogTests)", "{% get_admin_log %} works without specifying a user.", "test_non_integer_limit (admin_changelist.tests.GetAdminLogTests)", "test_without_as (admin_changelist.tests.GetAdminLogTests)"...
647480166bfe7532e8c471fef0146e3a17e6c0c9
15 min - 1 hour
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-15098
2c7846d992ca512d36a73f518205015c88ed088c
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -43,7 +43,7 @@ re.IGNORECASE ) -language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+)?)(/|$)') +language_code_prefix_re...
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -1593,22 +1593,41 @@ def test_get_supported_language_variant_null(self): @override_settings( LANGUAGES=[ ('en', 'English'), + ('en-latn-us', 'Latin English'), + ...
Internationalisation didn't support language locale containing both script and region. Description The i18n_patterns didn't work with locale contains both script and region, like en-latn-us. Given settings.py LANGUAGE_CODE = 'en-us' LANGUAGES = [ ('en-us', "English"), ('en-latn-us', "Latin English"), ('en-Latn-US'...
What's the use case of using en-latn-us? Replying to Claude Paroz: What's the use case of using en-latn-us? Our language, Taigi in Taiwan, is denoted by nan in ISO 639-3. nan denoted other languages which are different from Taigi although we are submitting the proposal for new language code this year. So that the langu...
2021-11-17T21:30:07Z
4.1
["test_get_language_from_path_real (i18n.tests.MiscTests)", "test_get_supported_language_variant_null (i18n.tests.MiscTests)"]
["OSError is raised if the default language is unparseable.", "test_ignores_non_mo_files (i18n.tests.TranslationFileChangedTests)", "test_resets_cache_with_mo_files (i18n.tests.TranslationFileChangedTests)", "test_round_away_from_one (i18n.tests.UtilsTests)", "test_lazy (i18n.tests.TestModels)", "test_safestr (i18n.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
15 min - 1 hour
django/django
django__django-15103
dd528cb2cefc0db8b91a7ff0a2bc87305b976597
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py --- a/django/template/defaultfilters.py +++ b/django/template/defaultfilters.py @@ -83,10 +83,10 @@ def escapejs_filter(value): @register.filter(is_safe=True) -def json_script(value, element_id): +def json_script(value, element_id=N...
diff --git a/tests/template_tests/filter_tests/test_json_script.py b/tests/template_tests/filter_tests/test_json_script.py --- a/tests/template_tests/filter_tests/test_json_script.py +++ b/tests/template_tests/filter_tests/test_json_script.py @@ -17,3 +17,8 @@ def test_basic(self): '{"a": "testing\\r\\njso...
Make the element_id argument of json_script optional Description I recently had a use-case where I wanted to use json_script but I didn't need any id for it (I was including the <script> inside a <template> so I didn't need an id to refer to it). I can't see any reason (security or otherwise) for the id to be require...
2021-11-19T15:57:54Z
4.1
["test_without_id (template_tests.filter_tests.test_json_script.JsonScriptTests)", "test_json_script_without_id (utils_tests.test_html.TestUtilsHtml)"]
["test_basic (template_tests.filter_tests.test_json_script.JsonScriptTests)", "test_conditional_escape (utils_tests.test_html.TestUtilsHtml)", "test_escape (utils_tests.test_html.TestUtilsHtml)", "test_escapejs (utils_tests.test_html.TestUtilsHtml)", "test_format_html (utils_tests.test_html.TestUtilsHtml)", "test_html_...
647480166bfe7532e8c471fef0146e3a17e6c0c9
15 min - 1 hour
django/django
django__django-15104
a7e7043c8746933dafce652507d3b821801cdc7d
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -96,7 +96,7 @@ def only_relation_agnostic_fields(self, fields): for name, field in sorted(fields.items()): deconstructio...
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -2834,6 +2834,28 @@ def test_parse_number(self): expected_number, ) + def test_add_custom_fk_wi...
KeyError with migration autodetector and FK field with hardcoded reference Description Hi, I encountered this issue on an old Django project (probably 10 years old) with tons of models and probably a lot of questionable design decisions. The symptom is that running our test suite in verbose mode doesn't work: $ pytho...
2021-11-19T20:46:58Z
4.1
["test_add_custom_fk_with_hardcoded_to (migrations.test_autodetector.AutodetectorTests)"]
["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest...
647480166bfe7532e8c471fef0146e3a17e6c0c9
<15 min fix
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-15161
96e7ff5e9ff6362d9a886545869ce4496ca4b0fb
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -651,6 +651,7 @@ def relabeled_clone(self, relabels): return self +@deconstructible(path='django.db.models.Func') class Func(SQLiteNumericMixin, Exp...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1763,14 +1763,14 @@ def test_update_UUIDField_using_Value(self): def test_deconstruct(self): value = Value('name') path, args, kwargs = value.deconstruct() - ...
Use simplified paths for deconstruct of expressions Description Previously F() deconstructed to: django.db.models.expressions.F(). But since it can also be imported from django.db.models, ​PR #14047 changed it to deconstruct to django.db.models.F(). This simplifies generated migration code where it will be referenced...
I would like to give this a try if someone can guide me on how to proceed with this problem. I don't think much more guidance can be given particular to this ticket. Did you see the example PR? Have you read the contributing guidelines and the first patch tutorial?
2021-12-06T09:06:13Z
4.1
["test_deconstruct (expressions.tests.ValueTests)", "test_deconstruct_output_field (expressions.tests.ValueTests)", "test_serialize_complex_func_index (migrations.test_writer.WriterTests)"]
["test_equal (expressions.tests.OrderByTests)", "test_hash (expressions.tests.OrderByTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTests)", "test_or (expressions.tests.CombinableTests)", "test_reversed_and (expressions.tests.CombinableTests)", "test_reversed_or (ex...
647480166bfe7532e8c471fef0146e3a17e6c0c9
15 min - 1 hour
django/django
django__django-15252
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
15 min - 1 hour
django/django
django__django-15268
0ab58c120939093fea90822f376e1866fc714d1f
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -34,9 +34,12 @@ def references_model(self, name, app_label): def reduce(self, operation, app_label): return ...
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -1573,21 +1573,13 @@ def test_foo_together_ordering(self): self.assertOperationTypes(changes, 'otherapp', 0, [ 'Alte...
Optimize multiple AlterFooTogether operations into one Description Hi, In #31503 we split the AlterFooTogether (AlterUniqueTogether and AlterIndexTogether) operations into two types of operations. First, a migration will have operations to remove constraints, and then other operations adds the new constraints. This a...
2022-01-01T09:57:13Z
4.1
["index/unique_together also triggers on ordering changes.", "Removed fields will be removed after updating index/unique_together.", "Fields are renamed before updating index/unique_together."]
["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest...
647480166bfe7532e8c471fef0146e3a17e6c0c9
1-4 hours
django/django
django__django-15277
30613d6a748fce18919ff8b0da166d9fda2ed9bc
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -1010,7 +1010,8 @@ class CharField(Field): def __init__(self, *args, db_collation=None, **kwargs): super().__init__(*args, **kwargs)...
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1852,6 +1852,30 @@ def test_resolve_output_field_failure(self): with self.assertRaisesMessage(FieldError, msg): Value(object()).output_field + def test_ou...
Micro-optimisation for Value._resolve_output_field (by modifying CharField.__init__) Description Currently, when you do something like annotate(x=Value('test')) that will eventually probably call down into Value._resolve_output_field() and run the following code: if isinstance(self.value, str): return fields.CharFie...
All tests passed in CI, PR is ​https://github.com/django/django/pull/15277 Force pushing a revised commit which includes a test case that errors without the change, for regression purposes.
2022-01-03T12:14:06Z
4.1
["The output field for a given Value doesn't get cleaned & validated,", "test_raise_empty_expressionlist (expressions.tests.ValueTests)"]
["test_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_non_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTests)", "test_or (expressions.tests.CombinableTests)", "test_reversed_and (expressions.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
<15 min fix
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-15280
973fa566521037ac140dcece73fceae50ee522f1
diff --git a/django/db/models/fields/related_descriptors.py b/django/db/models/fields/related_descriptors.py --- a/django/db/models/fields/related_descriptors.py +++ b/django/db/models/fields/related_descriptors.py @@ -646,8 +646,9 @@ def get_prefetch_queryset(self, instances, queryset=None): # Since we ju...
diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py --- a/tests/prefetch_related/tests.py +++ b/tests/prefetch_related/tests.py @@ -1614,3 +1614,29 @@ def test_retrieves_results_from_prefetched_objects_cache(self): with self.assertNumQueries(4): # AuthorWithAge -> Author...
Deferred fields incorrect when following prefetches back to the "parent" object Description Given the following models: class User(models.Model): email = models.EmailField() kind = models.CharField( max_length=10, choices=[("ADMIN", "Admin"), ("REGULAR", "Regular")] ) class Profile(models.Model): full_name = mo...
When using prefetch_related the retrieved objects are assigned their origin's foreign object so in this case the inner prefetch is performed but entirely discarded because it's the outer's query user (the ones with only email) that are assigned to the prefetched profiles. I guess we should either change the current beh...
2022-01-04T11:16:35Z
4.1
["The prefetched relationship is used rather than populating the reverse"]
["test_bug (prefetch_related.tests.Ticket21410Tests)", "test_bug (prefetch_related.tests.Ticket19607Tests)", "test_m2m_then_m2m (prefetch_related.tests.DefaultManagerTests)", "When intermediary results are prefetched without a destination", "test_bug (prefetch_related.tests.Ticket21760Tests)", "test_foreignkey (prefetc...
647480166bfe7532e8c471fef0146e3a17e6c0c9
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-15368
e972620ada4f9ed7bc57f28e133e85c85b0a7b20
diff --git a/django/db/models/query.py b/django/db/models/query.py --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -17,7 +17,7 @@ from django.db.models import AutoField, DateField, DateTimeField, sql from django.db.models.constants import LOOKUP_SEP, OnConflict from django.db.models.deletion impor...
diff --git a/tests/queries/test_bulk_update.py b/tests/queries/test_bulk_update.py --- a/tests/queries/test_bulk_update.py +++ b/tests/queries/test_bulk_update.py @@ -211,6 +211,16 @@ def test_field_references(self): Number.objects.bulk_update(numbers, ['num']) self.assertCountEqual(Number.objects.fil...
bulk_update() does not work with plain F('...') expressions. Description Repro: assign plain F(...) to some model instance field save with bulk_update Example: Code highlighting: >>> from exampleapp.models import SelfRef >>> o = SelfRef.objects.all().first() >>> o.c8 = F('name') # model has char fields 'c8' and 'name...
Thanks for the report. Agreed, we should check resolve_expression like elsewhere. Would you like to provide a patch? Sure, can do a patch. Is this worth to add a test case as well?
2022-01-27T13:44:35Z
4.1
["test_f_expression (queries.test_bulk_update.BulkUpdateTests)"]
["test_batch_size (queries.test_bulk_update.BulkUpdateNoteTests)", "test_foreign_keys_do_not_lookup (queries.test_bulk_update.BulkUpdateNoteTests)", "test_functions (queries.test_bulk_update.BulkUpdateNoteTests)", "test_multiple_fields (queries.test_bulk_update.BulkUpdateNoteTests)", "test_set_field_to_null (queries.te...
647480166bfe7532e8c471fef0146e3a17e6c0c9
<15 min fix
django/django
django__django-15375
beb7ddbcee03270e833b2f74927ccfc8027aa693
diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py --- a/django/db/models/aggregates.py +++ b/django/db/models/aggregates.py @@ -65,7 +65,9 @@ def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize if hasattr(default, 'resolve_expression'): defau...
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1630,6 +1630,18 @@ def test_aggregation_default_passed_another_aggregate(self): ) self.assertAlmostEqual(result['value'], Decimal('61.72'), places=2) + def te...
aggregate() with 'default' after annotate() crashes. Description I saw this on a PostgreSQL project and reproduced it with SQLite. Django 4.0.1. Annotate (anything) then aggregate works fine: $ ./manage.py shell Python 3.10.2 (main, Jan 21 2022, 19:45:54) [Clang 13.0.0 (clang-1300.0.29.30)] Type 'copyright', 'credits...
Thanks for the report! Would you like to prepare a patch? If not, you can assign it me as 4.0.2 will be issued on Tuesday. I have had a quick look but I got a bit lost. Aggregate.default generates a Coalesce internally so it seems a little lower level. If you have the capacity that would be appreciated. Replying to Ada...
2022-01-28T14:48:03Z
4.1
["test_aggregation_default_after_annotation (aggregation.tests.AggregateTestCase)"]
["test_add_implementation (aggregation.tests.AggregateTestCase)", "test_aggregate_alias (aggregation.tests.AggregateTestCase)", "test_aggregate_annotation (aggregation.tests.AggregateTestCase)", "test_aggregate_in_order_by (aggregation.tests.AggregateTestCase)", "test_aggregate_join_transform (aggregation.tests.Aggrega...
647480166bfe7532e8c471fef0146e3a17e6c0c9
15 min - 1 hour
django/django
django__django-15380
71e7c8e73712419626f1c2b6ec036e8559a2d667
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py --- a/django/db/migrations/autodetector.py +++ b/django/db/migrations/autodetector.py @@ -824,7 +824,7 @@ def generate_renamed_fields(self): for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_fi...
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -1049,6 +1049,26 @@ def test_rename_related_field_preserved_db_column(self): new_name='renamed_foo', ) + def te...
Migration autodetector crashes when renaming a model and field. Description Migration autodetector crashes when renaming a model and field in a single step: $ python manage.py makemigrations Did you rename the test_one.MyModel model to MyModel2? [y/N] y Traceback (most recent call last): File "manage.py", line 22, i...
2022-01-31T19:44:44Z
4.1
["test_rename_field_with_renamed_model (migrations.test_autodetector.AutodetectorTests)"]
["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest...
647480166bfe7532e8c471fef0146e3a17e6c0c9
<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-15467
e0442a628eb480eac6a7888aed5a86f83499e299
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -269,7 +269,9 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs): "class": get_ul_class(self.radio_fields[db_field.name])...
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -21,6 +21,7 @@ CharField, DateField, DateTimeField, + ForeignKey, ManyToManyField, UUIDField, ) @@ -141,6 +142,17 @@ def test_radio_fields_Foreig...
ModelAdmin with defined radio_fields override empty_label Description ModelAdmin drops my "empty_label" and set "default_empty_label". For example: class MyModelAdmin(ModelAdmin): radio_fields = 'myfield', def formfield_for_foreignkey(self, db_field, *args, **kwargs): if db_field.name == 'myfield': kwargs['emp...
Agreed, empty_label from kwargs should take precedence over _('None'). I want to work on this to get familiarised with contributing process. Assigning this to me.
2022-02-27T03:00:31Z
4.1
["test_radio_fields_foreignkey_formfield_overrides_empty_label (admin_widgets.tests.AdminFormfieldForDBFieldTests)"]
["test_CharField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_DateField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_DateTimeField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_EmailField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_FileField (admin_widgets.tes...
647480166bfe7532e8c471fef0146e3a17e6c0c9
<15 min fix
django/django
django__django-15499
d90e34c61b27fba2527834806639eebbcfab9631
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -170,6 +170,19 @@ def reduce(self, operation, app_label): managers=self.managers, ),...
diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py --- a/tests/migrations/test_optimizer.py +++ b/tests/migrations/test_optimizer.py @@ -129,6 +129,30 @@ def test_create_alter_model_options(self): ], ) + def test_create_alter_model_managers(self): + se...
Optimize CreateModel + AlterModelManagers to CreateModel Description During migration optimization, CreateModel + AlterModelOptions is reduced to just CreateModel, with the model options. Similarly, CreateModel + AlterModelManagers can become just CreateModel.
2022-03-10T22:32:35Z
4.1
["test_create_alter_model_managers (migrations.test_optimizer.OptimizerTests)"]
["AlterField should optimize into AddField.", "RemoveField should cancel AddField", "RenameField should optimize into AddField", "test_alter_alter_index_model (migrations.test_optimizer.OptimizerTests)", "test_alter_alter_owrt_model (migrations.test_optimizer.OptimizerTests)", "test_alter_alter_table_model (migrations....
647480166bfe7532e8c471fef0146e3a17e6c0c9
<15 min fix
django/django
django__django-15503
859a87d873ce7152af73ab851653b4e1c3ffea4c
diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py --- a/django/db/models/fields/json.py +++ b/django/db/models/fields/json.py @@ -172,6 +172,10 @@ def as_sql(self, compiler, connection): class HasKeyLookup(PostgresOperatorLookup): logical_operator = None + def compile_json_path_f...
diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fields/test_jsonfield.py @@ -576,6 +576,33 @@ def test_has_any_keys(self): [self.objs[3], self.objs[4], self.objs[6]], ) + def test_has_key_num...
has_key, has_keys, and has_any_keys JSONField() lookups don't handle numeric keys on SQLite, MySQL, and Oracle. Description (last modified by TheTerrasque) Problem When using models.​JSONField() ​has_key lookup with numerical keys on SQLite database it fails to find the keys. Versions: Django: 4.0.3 Python: 3.9...
Duplicate of #30566, see comment. Not a duplicate of #30566 This is django's models.JSONField() not postgres extension JSONField It works as expected on Postgresql, the bug is on SQLite #30566 goes directly against comments for https://code.djangoproject.com/ticket/29504 If different behavior is expected on SQLite (or ...
2022-03-12T06:22:37Z
4.1
["test_has_key_number (model_fields.test_jsonfield.TestQuerying)", "test_has_keys (model_fields.test_jsonfield.TestQuerying)"]
["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_custom_encoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_decoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_encoder (model_fields...
647480166bfe7532e8c471fef0146e3a17e6c0c9
1-4 hours
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-15554
59ab3fd0e9e606d7f0f7ca26609c06ee679ece97
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1011,7 +1011,7 @@ def count_active_tables(self): """ return len([1 for count in self.alias_refcount.values() if count]) - def join(self, join, reu...
diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py --- a/tests/filtered_relation/tests.py +++ b/tests/filtered_relation/tests.py @@ -211,6 +211,34 @@ def test_internal_queryset_alias_mapping(self): str(queryset.query), ) + def test_multiple(self): + qs = (...
Using multiple FilteredRelation with different filters but for same relation is ignored. Description (last modified by lind-marcus) I have a relation that ALWAYS have at least 1 entry with is_all=True and then I have an optional entry that could have is_all=False but instead have zone set. I'm trying to use Fil...
Thanks for the report! A regression test: tests/filtered_relation/tests.py diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py index 790a90d9e2..1208ddde5f 100644 a b class FilteredRelationTests(TestCase): 211211 str(queryset.query), 212212 ) 213213 214 def test_multiple(self): 215 qs = ( 2...
2022-03-29T10:12:46Z
4.1
["test_multiple (filtered_relation.tests.FilteredRelationTests)"]
["filtered_relation() not only improves performance but also creates", "test_aggregate (filtered_relation.tests.FilteredRelationAnalyticalAggregationTests)", "test_as_subquery (filtered_relation.tests.FilteredRelationTests)", "test_condition_deeper_relation_name (filtered_relation.tests.FilteredRelationTests)", "test_c...
647480166bfe7532e8c471fef0146e3a17e6c0c9
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