repo stringclasses 12
values | instance_id stringlengths 18 32 | base_commit stringlengths 40 40 | patch stringlengths 277 17.4k | test_patch stringlengths 367 26.6k | problem_statement stringlengths 3.83k 9.83k | hints_text stringlengths 0 15.4k | created_at stringdate 2013-01-25 05:19:16 2023-08-07 19:30:22 | version stringclasses 53
values | FAIL_TO_PASS stringlengths 12 32.6k | PASS_TO_PASS stringlengths 2 271k | environment_setup_commit stringclasses 80
values | difficulty stringclasses 4
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
astropy/astropy | astropy__astropy-14995 | b16c7d12ccbc7b2d20364b89fb44285bcbfede54 | diff --git a/astropy/nddata/mixins/ndarithmetic.py b/astropy/nddata/mixins/ndarithmetic.py
--- a/astropy/nddata/mixins/ndarithmetic.py
+++ b/astropy/nddata/mixins/ndarithmetic.py
@@ -520,10 +520,10 @@ def _arithmetic_mask(self, operation, operand, handle_mask, axis=None, **kwds):
elif self.mask is None and ope... | diff --git a/astropy/nddata/mixins/tests/test_ndarithmetic.py b/astropy/nddata/mixins/tests/test_ndarithmetic.py
--- a/astropy/nddata/mixins/tests/test_ndarithmetic.py
+++ b/astropy/nddata/mixins/tests/test_ndarithmetic.py
@@ -1310,3 +1310,42 @@ def test_raise_method_not_supported():
# raise error for unsupported ... | ## Issue Description
In **astropy v5.3**, the mask propagation logic for `NDDataRef` arithmetic operations fails with a `TypeError` when one of the operands does **not** have an associated mask (`mask=None`). This is a **regression from v5.2**, where the same operations work correctly.
Specifically, when performing a... | Welcome to Astropy 👋 and thank you for your first issue!
A project member will respond to you as soon as possible; in the meantime, please double-check the [guidelines for submitting issues](https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md#reporting-issues) and make sure you've provided the requested deta... | 2023-06-27T19:48:18Z | 5.2 | ["astropy/nddata/mixins/tests/test_ndarithmetic.py::test_nddata_bitmask_arithmetic"] | ["astropy/nddata/mixins/tests/test_ndarithmetic.py::test_arithmetics_data[data10-data20]", "astropy/nddata/mixins/tests/test_ndarithmetic.py::test_arithmetics_data[data11-data21]", "astropy/nddata/mixins/tests/test_ndarithmetic.py::test_arithmetics_data[data12-data22]", "astropy/nddata/mixins/tests/test_ndarithmetic.py... | 362f6df12abf9bd769d4915fabf955c993ea22cf | <15 min fix |
astropy/astropy | astropy__astropy-14096 | 1a4462d72eb03f30dc83a879b1dd57aac8b2c18b | diff --git a/astropy/coordinates/sky_coordinate.py b/astropy/coordinates/sky_coordinate.py
--- a/astropy/coordinates/sky_coordinate.py
+++ b/astropy/coordinates/sky_coordinate.py
@@ -894,10 +894,8 @@ def __getattr__(self, attr):
if frame_cls is not None and self.frame.is_transformable_to(frame_cls):
... | diff --git a/astropy/coordinates/tests/test_sky_coord.py b/astropy/coordinates/tests/test_sky_coord.py
--- a/astropy/coordinates/tests/test_sky_coord.py
+++ b/astropy/coordinates/tests/test_sky_coord.py
@@ -2165,3 +2165,21 @@ def test_match_to_catalog_3d_and_sky():
npt.assert_array_equal(idx, [0, 1, 2, 3])
as... | # Enhanced Problem Statement
## Issue Description
When subclassing `astropy.coordinates.SkyCoord` and adding custom properties that access non-existent attributes, the error message incorrectly reports that the custom property itself doesn't exist, rather than reporting the actual missing attribute within the propert... | This is because the property raises an `AttributeError`, which causes Python to call `__getattr__`. You can catch the `AttributeError` in the property and raise another exception with a better message.
The problem is it's a nightmare for debugging at the moment. If I had a bunch of different attributes in `prop(self)`,... | 2022-12-04T17:06:07Z | 5.1 | ["astropy/coordinates/tests/test_sky_coord.py::test_subclass_property_exception_error"] | ["astropy/coordinates/tests/test_sky_coord.py::test_is_transformable_to_str_input", "astropy/coordinates/tests/test_sky_coord.py::test_transform_to", "astropy/coordinates/tests/test_sky_coord.py::test_round_tripping[ICRS-ICRS-None-None-None-None]", "astropy/coordinates/tests/test_sky_coord.py::test_round_tripping[ICRS-... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-14539 | c0a24c1dc957a3b565294213f435fefb2ec99714 | diff --git a/astropy/io/fits/diff.py b/astropy/io/fits/diff.py
--- a/astropy/io/fits/diff.py
+++ b/astropy/io/fits/diff.py
@@ -1449,7 +1449,7 @@ def _diff(self):
arrb.dtype, np.floating
):
diffs = where_not_allclose(arra, arrb, rtol=self.rtol, atol=self.atol)
- ... | diff --git a/astropy/io/fits/tests/test_diff.py b/astropy/io/fits/tests/test_diff.py
--- a/astropy/io/fits/tests/test_diff.py
+++ b/astropy/io/fits/tests/test_diff.py
@@ -406,16 +406,17 @@ def test_identical_tables(self):
c8 = Column("H", format="C", array=[0.0 + 1.0j, 2.0 + 3.0j])
c9 = Column("I", fo... | # Problem Statement: `io.fits.FITSDiff` Reports False Differences in Identical Files with VLA Columns
## Issue Description
The `astropy.io.fits.FITSDiff` utility may report false differences when comparing FITS files that are identical, particularly when those files contain Variable-Length Array (VLA) columns. The is... | Seems due to the use of `Q`, only `P` is handled in the diff code. This:
```
--- astropy/io/fits/diff.py
+++ astropy/io/fits/diff.py
@@ -1449,7 +1449,7 @@ class TableDataDiff(_BaseDiff):
arrb.dtype, np.floating
):
diffs = where_not_allclose(arra, arrb, rtol=self.rto... | 2023-03-16T18:45:19Z | 5.1 | ["astropy/io/fits/tests/test_diff.py::TestDiff::test_identical_tables", "astropy/io/fits/tests/test_diff.py::TestDiff::test_different_table_data"] | ["astropy/io/fits/tests/test_diff.py::TestDiff::test_identical_headers", "astropy/io/fits/tests/test_diff.py::TestDiff::test_slightly_different_headers", "astropy/io/fits/tests/test_diff.py::TestDiff::test_common_keywords", "astropy/io/fits/tests/test_diff.py::TestDiff::test_different_keyword_count", "astropy/io/fits/t... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-13453 | 19cc80471739bcb67b7e8099246b391c355023ee | diff --git a/astropy/io/ascii/html.py b/astropy/io/ascii/html.py
--- a/astropy/io/ascii/html.py
+++ b/astropy/io/ascii/html.py
@@ -349,11 +349,13 @@ def write(self, table):
cols = list(table.columns.values())
self.data.header.cols = cols
+ self.data.cols = cols
if isinstance(self.d... | diff --git a/astropy/io/ascii/tests/test_html.py b/astropy/io/ascii/tests/test_html.py
--- a/astropy/io/ascii/tests/test_html.py
+++ b/astropy/io/ascii/tests/test_html.py
@@ -717,6 +717,49 @@ def test_multi_column_write_table_html_fill_values_masked():
assert buffer_output.getvalue() == buffer_expected.getvalue()
... | ## Issue Description
The issue is that when writing an Astropy `Table` to HTML format using the `formats` parameter, custom formatting functions or format specifiers are ignored. The same `formats` parameter works correctly with other ASCII output formats like CSV, RST, and MRT, but the HTML writer fails to apply the ... | Welcome to Astropy 👋 and thank you for your first issue!
A project member will respond to you as soon as possible; in the meantime, please double-check the [guidelines for submitting issues](https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md#reporting-issues) and make sure you've provided the requested deta... | 2022-07-14T10:04:40Z | 5.0 | ["astropy/io/ascii/tests/test_html.py::test_write_table_formatted_columns"] | ["astropy/io/ascii/tests/test_html.py::test_listwriter", "astropy/io/ascii/tests/test_html.py::test_htmlinputter_no_bs4", "astropy/io/ascii/tests/test_html.py::test_multicolumn_write", "astropy/io/ascii/tests/test_html.py::test_write_no_multicols", "astropy/io/ascii/tests/test_html.py::test_write_table_html_fill_values... | cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-7166 | 26d147868f8a891a6009a25cd6a8576d2e1bd747 | diff --git a/astropy/utils/misc.py b/astropy/utils/misc.py
--- a/astropy/utils/misc.py
+++ b/astropy/utils/misc.py
@@ -4,9 +4,6 @@
A "grab bag" of relatively small general-purpose utilities that don't have
a clear module/package to live in.
"""
-
-
-
import abc
import contextlib
import difflib
@@ -27,7 +24,6 @@
... | diff --git a/astropy/utils/tests/test_misc.py b/astropy/utils/tests/test_misc.py
--- a/astropy/utils/tests/test_misc.py
+++ b/astropy/utils/tests/test_misc.py
@@ -80,14 +80,26 @@ def __call__(self, *args):
"FOO"
pass
+ @property
+ def bar(self):
+ "BAR"
+ ... | ## Issue Description
The `InheritDocstrings` metaclass in `astropy.utils.misc` fails to properly inherit docstrings for properties because it uses `inspect.isfunction()` to detect callable attributes eligible for docstring inheritance. Since `inspect.isfunction()` returns `False` for property descriptors, properties a... | This was as implemented back in #2159. I don't see any `inspect.isproperty`. Do you have any suggestions?
I guess it should work with [inspect.isdatadescriptor](https://docs.python.org/3/library/inspect.html#inspect.isdatadescriptor).
And I wonder if this class is still needed, it seems that it started with #2136 for... | 2018-02-07T15:05:31Z | 1.3 | ["astropy/utils/tests/test_misc.py::test_inherit_docstrings"] | ["astropy/utils/tests/test_misc.py::test_isiterable", "astropy/utils/tests/test_misc.py::test_signal_number_to_name_no_failure", "astropy/utils/tests/test_misc.py::test_skip_hidden", "astropy/utils/tests/test_misc.py::test_JsonCustomEncoder", "astropy/utils/tests/test_misc.py::test_check_broadcast", "astropy/utils/test... | 848c8fa21332abd66b44efe3cb48b72377fb32cc | <15 min fix |
astropy/astropy | astropy__astropy-13977 | 5250b2442501e6c671c6b380536f1edb352602d1 | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -633,53 +633,70 @@ def __array_ufunc__(self, function, method, *inputs, **kwargs):
Returns
-------
- result : `~astropy.units.Quantity`
+ result : `~ast... | diff --git a/astropy/units/tests/test_quantity.py b/astropy/units/tests/test_quantity.py
--- a/astropy/units/tests/test_quantity.py
+++ b/astropy/units/tests/test_quantity.py
@@ -505,11 +505,10 @@ def test_incompatible_units(self):
def test_non_number_type(self):
q1 = u.Quantity(11.412, unit=u.meter)
- ... | # Enhanced Problem Statement
## Issue Description
The core issue is that `astropy.units.Quantity.__array_ufunc__()` raises a `ValueError` instead of returning `NotImplemented` when it encounters incompatible inputs (specifically custom array-like objects with incompatible units). This prevents Python's operator dispa... | @byrdie - I think you are right that really one should return `NotImplemented`. In general, the idea is indeed that one only works on classes that are recognized, while in the implementation that we have (which I wrote...) essentially everything that has a `unit` attribute is treated as a `Quantity`. I think it is a go... | 2022-11-01T22:24:58Z | 5.1 | ["astropy/units/tests/test_quantity_ufuncs.py::TestUfuncReturnsNotImplemented::TestBinaryUfuncs::test_full[None-duck_quantity0-quantity0-add]", "astropy/units/tests/test_quantity_ufuncs.py::TestUfuncReturnsNotImplemented::TestBinaryUfuncs::test_full[None-duck_quantity0-quantity0-less]", "astropy/units/tests/test_quanti... | ["astropy/units/tests/test_quantity.py::TestQuantityCreation::test_1", "astropy/units/tests/test_quantity.py::TestQuantityCreation::test_2", "astropy/units/tests/test_quantity.py::TestQuantityCreation::test_3", "astropy/units/tests/test_quantity.py::TestQuantityCreation::test_nan_inf", "astropy/units/tests/test_quantit... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-14182 | a5917978be39d13cd90b517e1de4e7a539ffaa48 | diff --git a/astropy/io/ascii/rst.py b/astropy/io/ascii/rst.py
--- a/astropy/io/ascii/rst.py
+++ b/astropy/io/ascii/rst.py
@@ -27,7 +27,6 @@ def get_fixedwidth_params(self, line):
class SimpleRSTData(FixedWidthData):
- start_line = 3
end_line = -1
splitter_class = FixedWidthTwoLineDataSplitter
@@ -3... | diff --git a/astropy/io/ascii/tests/test_rst.py b/astropy/io/ascii/tests/test_rst.py
--- a/astropy/io/ascii/tests/test_rst.py
+++ b/astropy/io/ascii/tests/test_rst.py
@@ -2,7 +2,11 @@
from io import StringIO
+import numpy as np
+
+import astropy.units as u
from astropy.io import ascii
+from astropy.table import Q... | ## Issue Description
The `astropy` package currently supports writing `Table` objects in RestructuredText (RST) format via `ascii.rst`, but it **does not accept the `header_rows` parameter**, unlike other ASCII formats such as `ascii.fixed_width`. When attempting to use `header_rows` with the RST format, a `TypeError`... | 2022-12-16T11:13:37Z | 5.1 | ["astropy/io/ascii/tests/test_rst.py::test_rst_with_header_rows"] | ["astropy/io/ascii/tests/test_rst.py::test_read_normal", "astropy/io/ascii/tests/test_rst.py::test_read_normal_names", "astropy/io/ascii/tests/test_rst.py::test_read_normal_names_include", "astropy/io/ascii/tests/test_rst.py::test_read_normal_exclude", "astropy/io/ascii/tests/test_rst.py::test_read_unbounded_right_colu... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 15 min - 1 hour | |
astropy/astropy | astropy__astropy-13236 | 6ed769d58d89380ebaa1ef52b300691eefda8928 | diff --git a/astropy/table/table.py b/astropy/table/table.py
--- a/astropy/table/table.py
+++ b/astropy/table/table.py
@@ -1239,13 +1239,6 @@ def _convert_data_to_col(self, data, copy=True, default_name=None, dtype=None, n
f'{fully_qualified_name} '
'did... | diff --git a/astropy/table/tests/test_mixin.py b/astropy/table/tests/test_mixin.py
--- a/astropy/table/tests/test_mixin.py
+++ b/astropy/table/tests/test_mixin.py
@@ -697,11 +697,13 @@ def test_skycoord_representation():
'1.0,90.0,0.0']
-def test_ndarray_mixin():
+@pytest.mark.parametriz... | # Issue Description
When structured NumPy arrays (arrays with multiple named fields in their dtype) are added to an Astropy Table, they are automatically transformed into `NdarrayMixin` objects. This auto-transformation was originally implemented as a workaround because structured dtype Columns had serialization and I... | @mhvk - I'm happy to do this PR if you think it is a good idea.
I agree there no longer is any reason to put structured arrays into `NdarrayMixin` -- indeed, I thought I had already changed its use! So, yes, happy to go ahead and create structured columns directly.
So you think we should change it now, or do a release ... | 2022-05-09T14:16:30Z | 5.0 | ["astropy/table/tests/test_mixin.py::test_ndarray_mixin[False]", "astropy/table/tests/test_table.py::test_structured_masked_column"] | ["astropy/table/tests/test_mixin.py::test_attributes[arrayswap]", "astropy/table/tests/test_mixin.py::test_attributes[arraywrap]", "astropy/table/tests/test_mixin.py::test_attributes[cartesianrep]", "astropy/table/tests/test_mixin.py::test_attributes[earthlocation]", "astropy/table/tests/test_mixin.py::test_attributes[... | cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-14309 | cdb66059a2feb44ee49021874605ba90801f9986 | diff --git a/astropy/io/fits/connect.py b/astropy/io/fits/connect.py
--- a/astropy/io/fits/connect.py
+++ b/astropy/io/fits/connect.py
@@ -65,10 +65,9 @@ def is_fits(origin, filepath, fileobj, *args, **kwargs):
fileobj.seek(pos)
return sig == FITS_SIGNATURE
elif filepath is not None:
- if ... | diff --git a/astropy/io/fits/tests/test_connect.py b/astropy/io/fits/tests/test_connect.py
--- a/astropy/io/fits/tests/test_connect.py
+++ b/astropy/io/fits/tests/test_connect.py
@@ -7,7 +7,14 @@
from astropy import units as u
from astropy.io import fits
-from astropy.io.fits import BinTableHDU, HDUList, ImageHDU, ... | ## Issue Description
An `IndexError: tuple index out of range` is occurring in the `identify_format` function within the `astropy.io.registry` system. The error arises when the FITS format identifier function (`is_fits`) attempts to access `args[0]` without validating that the `args` tuple contains any elements. This ... | cc @nstarman from #14274 | 2023-01-23T22:34:01Z | 5.1 | ["astropy/io/fits/tests/test_connect.py::test_is_fits_gh_14305"] | ["astropy/io/fits/tests/test_connect.py::TestSingleTable::test_simple", "astropy/io/fits/tests/test_connect.py::TestSingleTable::test_simple_pathlib", "astropy/io/fits/tests/test_connect.py::TestSingleTable::test_simple_meta", "astropy/io/fits/tests/test_connect.py::TestSingleTable::test_simple_meta_conflicting", "astr... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | <15 min fix |
astropy/astropy | astropy__astropy-14508 | a3f4ae6cd24d5ecdf49f213d77b3513dd509a06c | diff --git a/astropy/io/fits/card.py b/astropy/io/fits/card.py
--- a/astropy/io/fits/card.py
+++ b/astropy/io/fits/card.py
@@ -1298,31 +1298,17 @@ def _format_value(value):
def _format_float(value):
- """Format a floating number to make sure it gets the decimal point."""
- value_str = f"{value:.16G}"
- if... | diff --git a/astropy/io/fits/tests/test_header.py b/astropy/io/fits/tests/test_header.py
--- a/astropy/io/fits/tests/test_header.py
+++ b/astropy/io/fits/tests/test_header.py
@@ -137,6 +137,27 @@ def test_floating_point_value_card(self):
):
assert str(c) == _pad("FLOATNUM= -4.6737463674763E+32")
... | # Enhanced Problem Statement: Improper Float Formatting in `io.fits.Card`
## Issue Description
The `astropy.io.fits.Card` class unnecessarily expands floating-point values to their full precision representation when creating new cards, causing valid FITS headers to become impossible to construct due to comment trunca... | Agreed this is a bug. As far as I know, python floats by default now have reprs that use the right number of digits to be reproducible. So I think replacing this by `value_str = str(value)` should be totally fine. Do you want to try that and run the tests, to see if it works? If so, I think we should make that change ... | 2023-03-09T11:08:51Z | 5.1 | ["astropy/io/fits/tests/test_header.py::TestHeaderFunctions::test_floating_point_string_representation_card"] | ["astropy/io/fits/tests/test_header.py::test_shallow_copy", "astropy/io/fits/tests/test_header.py::test_init_with_header", "astropy/io/fits/tests/test_header.py::test_init_with_dict", "astropy/io/fits/tests/test_header.py::test_init_with_ordereddict", "astropy/io/fits/tests/test_header.py::TestHeaderFunctions::test_ren... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-14365 | 7269fa3e33e8d02485a647da91a5a2a60a06af61 | diff --git a/astropy/io/ascii/qdp.py b/astropy/io/ascii/qdp.py
--- a/astropy/io/ascii/qdp.py
+++ b/astropy/io/ascii/qdp.py
@@ -68,7 +68,7 @@ def _line_type(line, delimiter=None):
_new_re = rf"NO({sep}NO)+"
_data_re = rf"({_decimal_re}|NO|[-+]?nan)({sep}({_decimal_re}|NO|[-+]?nan))*)"
_type_re = rf"^\s*((... | diff --git a/astropy/io/ascii/tests/test_qdp.py b/astropy/io/ascii/tests/test_qdp.py
--- a/astropy/io/ascii/tests/test_qdp.py
+++ b/astropy/io/ascii/tests/test_qdp.py
@@ -43,7 +43,18 @@ def test_get_tables_from_qdp_file(tmp_path):
assert np.isclose(table2["MJD_nerr"][0], -2.37847222222222e-05)
-def test_roundt... | ## Issue Description
The ASCII QDP reader in `astropy.io.ascii.qdp` enforces strict uppercase parsing of QDP command keywords such as `READ`, `SERR`, and `TERR`. However, the QDP standard is case-insensitive, meaning that lowercase or mixed-case commands like `read serr 1 2` should be valid. As a result, when users ma... | Welcome to Astropy 👋 and thank you for your first issue!
A project member will respond to you as soon as possible; in the meantime, please double-check the [guidelines for submitting issues](https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md#reporting-issues) and make sure you've provided the requested deta... | 2023-02-06T19:20:34Z | 5.1 | ["astropy/io/ascii/tests/test_qdp.py::test_roundtrip[True]"] | ["astropy/io/ascii/tests/test_qdp.py::test_get_tables_from_qdp_file", "astropy/io/ascii/tests/test_qdp.py::test_roundtrip[False]", "astropy/io/ascii/tests/test_qdp.py::test_read_example", "astropy/io/ascii/tests/test_qdp.py::test_roundtrip_example", "astropy/io/ascii/tests/test_qdp.py::test_roundtrip_example_comma", "a... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-7336 | 732d89c2940156bdc0e200bb36dc38b5e424bcba | diff --git a/astropy/units/decorators.py b/astropy/units/decorators.py
--- a/astropy/units/decorators.py
+++ b/astropy/units/decorators.py
@@ -220,7 +220,7 @@ def wrapper(*func_args, **func_kwargs):
# Call the original function with any equivalencies in force.
with add_enabled_equivalencies(se... | diff --git a/astropy/units/tests/py3_test_quantity_annotations.py b/astropy/units/tests/test_quantity_annotations.py
similarity index 60%
rename from astropy/units/tests/py3_test_quantity_annotations.py
rename to astropy/units/tests/test_quantity_annotations.py
--- a/astropy/units/tests/py3_test_quantity_annotations.py... | # Enhanced Problem Statement
## Issue Description
The `@u.quantity_input` decorator fails when applied to constructor methods (`__init__`) that have explicit type hints with `-> None` return annotations. This occurs because the decorator's internal logic attempts to convert the return value using the `.to()` method, ... | `git blame` says #3072 -- @Cadair !
yeah, I did add this feature... | 2018-03-28T15:31:32Z | 1.3 | ["astropy/units/tests/test_quantity_annotations.py::test_return_annotation_none"] | ["astropy/units/tests/test_quantity_annotations.py::test_args3[solarx_unit0-solary_unit0]", "astropy/units/tests/test_quantity_annotations.py::test_args3[angle-angle]", "astropy/units/tests/test_quantity_annotations.py::test_args_noconvert3[solarx_unit0-solary_unit0]", "astropy/units/tests/test_quantity_annotations.py:... | 848c8fa21332abd66b44efe3cb48b72377fb32cc | <15 min fix |
astropy/astropy | astropy__astropy-12907 | d16bfe05a744909de4b27f5875fe0d4ed41ce607 | diff --git a/astropy/modeling/separable.py b/astropy/modeling/separable.py
--- a/astropy/modeling/separable.py
+++ b/astropy/modeling/separable.py
@@ -242,7 +242,7 @@ def _cstack(left, right):
cright = _coord_matrix(right, 'right', noutp)
else:
cright = np.zeros((noutp, right.shape[1]))
- ... | diff --git a/astropy/modeling/tests/test_separable.py b/astropy/modeling/tests/test_separable.py
--- a/astropy/modeling/tests/test_separable.py
+++ b/astropy/modeling/tests/test_separable.py
@@ -28,6 +28,13 @@
p1 = models.Polynomial1D(1, name='p1')
+cm_4d_expected = (np.array([False, False, True, True]),
+ ... | # Enhanced Problem Statement: Separability Matrix Computation for Nested CompoundModels
## Issue Description
The separability matrix computation in Astropy's modeling framework incorrectly handles nested `CompoundModel` structures. When a `CompoundModel` created via the `&` operator is itself combined with other mode... | 2022-03-03T15:14:54Z | 4.3 | ["astropy/modeling/tests/test_separable.py::test_separable[compound_model6-result6]", "astropy/modeling/tests/test_separable.py::test_separable[compound_model9-result9]"] | ["astropy/modeling/tests/test_separable.py::test_coord_matrix", "astropy/modeling/tests/test_separable.py::test_cdot", "astropy/modeling/tests/test_separable.py::test_cstack", "astropy/modeling/tests/test_separable.py::test_arith_oper", "astropy/modeling/tests/test_separable.py::test_separable[compound_model0-result0]"... | 298ccb478e6bf092953bca67a3d29dc6c35f6752 | 15 min - 1 hour | |
astropy/astropy | astropy__astropy-14598 | 80c3854a5f4f4a6ab86c03d9db7854767fcd83c1 | diff --git a/astropy/io/fits/card.py b/astropy/io/fits/card.py
--- a/astropy/io/fits/card.py
+++ b/astropy/io/fits/card.py
@@ -66,7 +66,7 @@ class Card(_Verify):
# followed by an optional comment
_strg = r"\'(?P<strg>([ -~]+?|\'\'|) *?)\'(?=$|/| )"
_comm_field = r"(?P<comm_field>(?P<sepr>/ *)(?P<comm>(.|... | diff --git a/astropy/io/fits/tests/test_header.py b/astropy/io/fits/tests/test_header.py
--- a/astropy/io/fits/tests/test_header.py
+++ b/astropy/io/fits/tests/test_header.py
@@ -582,6 +582,22 @@ def test_long_string_value_via_fromstring(self, capsys):
"CONTINUE '' / comments in line 1 comments with '... | # Comprehensive Problem Statement: Inconsistency in Double Single-Quote (`''`) Management in FITS Cards
## Issue Description
The `astropy.io.fits` module incorrectly handles double single-quotes (`''`) in FITS card values under specific conditions, leading to data corruption when cards are serialized to strings and t... | Hello, I would like to be assigned to this issue if possible. Thank you.
Hi @ashtonw3,
We don't usually assign people to issues, mentioning here that you want to work on it is enough.
But on this specific issue I already have a fix and will open a PR soon, I was going to do that yesterday but I found another related ... | 2023-03-29T10:34:49Z | 5.2 | ["astropy/io/fits/tests/test_header.py::TestHeaderFunctions::test_long_string_value_with_quotes"] | ["astropy/io/fits/tests/test_header.py::test_shallow_copy", "astropy/io/fits/tests/test_header.py::test_init_with_header", "astropy/io/fits/tests/test_header.py::test_init_with_dict", "astropy/io/fits/tests/test_header.py::test_init_with_ordereddict", "astropy/io/fits/tests/test_header.py::TestHeaderFunctions::test_ren... | 362f6df12abf9bd769d4915fabf955c993ea22cf | 15 min - 1 hour |
astropy/astropy | astropy__astropy-13033 | 298ccb478e6bf092953bca67a3d29dc6c35f6752 | diff --git a/astropy/timeseries/core.py b/astropy/timeseries/core.py
--- a/astropy/timeseries/core.py
+++ b/astropy/timeseries/core.py
@@ -55,6 +55,13 @@ class BaseTimeSeries(QTable):
_required_columns_relax = False
def _check_required_columns(self):
+ def as_scalar_or_list_str(obj):
+ if ... | diff --git a/astropy/timeseries/tests/test_sampled.py b/astropy/timeseries/tests/test_sampled.py
--- a/astropy/timeseries/tests/test_sampled.py
+++ b/astropy/timeseries/tests/test_sampled.py
@@ -395,6 +395,14 @@ def test_required_columns():
assert exc.value.args[0] == ("TimeSeries object is invalid - expected "
... | # Enhanced Problem Statement
## Issue Description
The `TimeSeries` class in Astropy produces a misleading error message when required column validation fails after column removal operations. When a `TimeSeries` object has custom required columns (beyond the default 'time' column) and a user attempts to remove one of t... | The relevant code that produces the misleading exception.
https://github.com/astropy/astropy/blob/00ccfe76113dca48d19396986872203dc2e978d7/astropy/timeseries/core.py#L77-L82
It works under the assumption that `time` is the only required column. So when a `TimeSeries` object has additional required columns, the me... | 2022-03-31T23:28:27Z | 4.3 | ["astropy/timeseries/tests/test_sampled.py::test_required_columns"] | ["astropy/timeseries/tests/test_sampled.py::test_empty_initialization", "astropy/timeseries/tests/test_sampled.py::test_empty_initialization_invalid", "astropy/timeseries/tests/test_sampled.py::test_initialize_only_time", "astropy/timeseries/tests/test_sampled.py::test_initialization_with_data", "astropy/timeseries/tes... | 298ccb478e6bf092953bca67a3d29dc6c35f6752 | 15 min - 1 hour |
astropy/astropy | astropy__astropy-14369 | fa4e8d1cd279acf9b24560813c8652494ccd5922 | diff --git a/astropy/units/format/cds.py b/astropy/units/format/cds.py
--- a/astropy/units/format/cds.py
+++ b/astropy/units/format/cds.py
@@ -138,8 +138,7 @@ def _make_parser(cls):
for Astronomical Catalogues 2.0
<http://vizier.u-strasbg.fr/vizier/doc/catstd-3.2.htx>`_, which is not
terribly... | diff --git a/astropy/units/tests/test_format.py b/astropy/units/tests/test_format.py
--- a/astropy/units/tests/test_format.py
+++ b/astropy/units/tests/test_format.py
@@ -60,9 +60,13 @@ def test_unit_grammar_fail(string):
(["mW/m2"], u.Unit(u.erg / u.cm**2 / u.s)),
(["mW/(m2)"], u.Unit(u.erg / u.cm**2... | ## Issue Description
When reading MRT (Machine-Readable Table) files using `astropy.table` with `format='ascii.cds'`, **complex composite units are incorrectly parsed**, specifically with **division operator ordering being jumbled**. For instance, a unit like `10+3J/m/s/kpc2` should represent energy flux density per u... | Welcome to Astropy 👋 and thank you for your first issue!
A project member will respond to you as soon as possible; in the meantime, please double-check the [guidelines for submitting issues](https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md#reporting-issues) and make sure you've provided the requested deta... | 2023-02-06T21:56:51Z | 5.1 | ["astropy/units/tests/test_format.py::test_cds_grammar[strings4-unit4]", "astropy/units/tests/test_format.py::test_cds_grammar[strings6-unit6]", "astropy/units/tests/test_format.py::test_cds_grammar_fail[km/s.Mpc-1]"] | ["astropy/units/tests/test_format.py::test_unit_grammar[strings0-unit0]", "astropy/units/tests/test_format.py::test_unit_grammar[strings1-unit1]", "astropy/units/tests/test_format.py::test_unit_grammar[strings2-unit2]", "astropy/units/tests/test_format.py::test_unit_grammar[strings3-unit3]", "astropy/units/tests/test_f... | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | 1-4 hours |
astropy/astropy | astropy__astropy-13398 | 6500928dc0e57be8f06d1162eacc3ba5e2eff692 | diff --git a/astropy/coordinates/builtin_frames/__init__.py b/astropy/coordinates/builtin_frames/__init__.py
--- a/astropy/coordinates/builtin_frames/__init__.py
+++ b/astropy/coordinates/builtin_frames/__init__.py
@@ -48,6 +48,7 @@
from . import icrs_cirs_transforms
from . import cirs_observed_transforms
from . imp... | diff --git a/astropy/coordinates/tests/test_intermediate_transformations.py b/astropy/coordinates/tests/test_intermediate_transformations.py
--- a/astropy/coordinates/tests/test_intermediate_transformations.py
+++ b/astropy/coordinates/tests/test_intermediate_transformations.py
@@ -194,6 +194,116 @@ def test_cirs_to_ha... | ## Issue Description
The astropy coordinate transformation system currently suffers from confusing and inaccurate behavior when transforming **ITRS (International Terrestrial Reference System)** coordinates to **topocentric observed frames** like `AltAz` and `HADec`. This recurring issue appears when users attempt to ... | cc @StuartLittlefair, @adrn, @eteq, @eerovaher, @mhvk
Yes, would be good to address this recurring problem. But we somehow have to ensure it gets used only when relevant. For instance, the coordinates better have a distance, and I suspect it has to be near Earth...
Yeah, so far I've made no attempt at hardening this a... | 2022-06-24T15:22:11Z | 5.0 | ["astropy/coordinates/tests/test_intermediate_transformations.py::test_itrs_topo_to_altaz_with_refraction", "astropy/coordinates/tests/test_intermediate_transformations.py::test_itrs_topo_to_hadec_with_refraction", "astropy/coordinates/tests/test_intermediate_transformations.py::test_cirs_itrs_topo", "astropy/coordinat... | ["astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs[icoo0]", "astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs[icoo1]", "astropy/coordinates/tests/test_intermediate_transformations.py::test_icrs_gcrs_dist_diff[gframe0]", "astropy/coordinates/tests/test_intermed... | cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 | 1-4 hours |
astropy/astropy | astropy__astropy-13579 | 0df94ff7097961e92fd7812036a24b145bc13ca8 | diff --git a/astropy/wcs/wcsapi/wrappers/sliced_wcs.py b/astropy/wcs/wcsapi/wrappers/sliced_wcs.py
--- a/astropy/wcs/wcsapi/wrappers/sliced_wcs.py
+++ b/astropy/wcs/wcsapi/wrappers/sliced_wcs.py
@@ -243,6 +243,8 @@ def pixel_to_world_values(self, *pixel_arrays):
return world_arrays
def world_to_pixel_va... | diff --git a/astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py b/astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py
--- a/astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py
+++ b/astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py
@@ -899,3 +899,39 @@ def test_pixel_to_world_values_different_int_types():
f... | # Problem Statement: Inconsistent Behavior of `world_to_pixel` in `SlicedLowLevelWCS`
## Issue Description
The `SlicedLowLevelWCS` class in Astropy produces incorrect results when performing `world_to_pixel` transformations on sliced World Coordinate System (WCS) objects. Specifically, when a 3D WCS with coupled spat... | A slightly shorter script to reproduce the issue is this (starting from the definition of `fits_wcs` in the OP):
```python
sl = SlicedLowLevelWCS(fits_wcs, 0)
world = fits_wcs.pixel_to_world_values(0,0,0)
out_pix = sl.world_to_pixel_values(world[0], world[1])
assert np.allclose(out_pix[0], 0)
```
The root ... | 2022-08-26T15:06:53Z | 5.0 | ["astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py::test_coupled_world_slicing"] | ["astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py::test_invalid_slices", "astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py::test_sanitize_slice[item0-4-expected0]", "astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs.py::test_sanitize_slice[item1-5-expected1]", "astropy/wcs/wcsapi/wrappers/tests/test_sliced_wcs... | cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 | 1-4 hours |
astropy/astropy | astropy__astropy-7606 | 3cedd79e6c121910220f8e6df77c54a0b344ea94 | diff --git a/astropy/units/core.py b/astropy/units/core.py
--- a/astropy/units/core.py
+++ b/astropy/units/core.py
@@ -728,7 +728,7 @@ def __eq__(self, other):
try:
other = Unit(other, parse_strict='silent')
except (ValueError, UnitsError, TypeError):
- return False
+ ... | diff --git a/astropy/units/tests/test_units.py b/astropy/units/tests/test_units.py
--- a/astropy/units/tests/test_units.py
+++ b/astropy/units/tests/test_units.py
@@ -185,6 +185,13 @@ def test_unknown_unit3():
assert unit != unit3
assert not unit.is_equivalent(unit3)
+ # Also test basic (in)equalities.
+... | ## Issue Description
When comparing an `UnrecognizedUnit` instance to `None` using the equality operator (`==`), a `TypeError` is raised instead of returning `False` as expected. This occurs because the `UnrecognizedUnit.__eq__` method attempts to convert `None` into a `Unit` object via `Unit(other, parse_strict='sile... | `x is None` works fine. Is there a reason why `==` is needed here?
`x is None` would indeed be preferred, but `==` should never fail, so this is still a bug. | 2018-06-29T16:27:46Z | 1.3 | ["astropy/units/tests/test_units.py::test_unknown_unit3"] | ["astropy/units/tests/test_units.py::test_getting_started", "astropy/units/tests/test_units.py::test_initialisation", "astropy/units/tests/test_units.py::test_invalid_power", "astropy/units/tests/test_units.py::test_invalid_compare", "astropy/units/tests/test_units.py::test_convert", "astropy/units/tests/test_units.py:... | 848c8fa21332abd66b44efe3cb48b72377fb32cc | 15 min - 1 hour |
astropy/astropy | astropy__astropy-7671 | a7141cd90019b62688d507ae056298507678c058 | diff --git a/astropy/utils/introspection.py b/astropy/utils/introspection.py
--- a/astropy/utils/introspection.py
+++ b/astropy/utils/introspection.py
@@ -4,6 +4,7 @@
import inspect
+import re
import types
import importlib
from distutils.version import LooseVersion
@@ -139,6 +140,14 @@ def minversion(module, ve... | diff --git a/astropy/utils/tests/test_introspection.py b/astropy/utils/tests/test_introspection.py
--- a/astropy/utils/tests/test_introspection.py
+++ b/astropy/utils/tests/test_introspection.py
@@ -67,7 +67,7 @@ def test_minversion():
from types import ModuleType
test_module = ModuleType(str("test_module"))
... | ## Issue Description
The `minversion` utility function in `astropy.utils.introspection` fails with a `TypeError` when comparing version strings like `'1.14.3'` against development versions such as `'1.14dev'`. This is caused by Python's built-in `distutils.version.LooseVersion`, which cannot compare version components... | Oops, sounds like we should put the regex back in that was there for `LooseVersion` - definitely don't want to go back to `pkg_resources`...
Huh I don't understand why I couldn't reproduce this before. Well I guess we know why that regexp was there before!
@mhvk - will you open a PR to restore the regexp? | 2018-07-20T19:37:49Z | 1.3 | ["astropy/utils/tests/test_introspection.py::test_minversion"] | ["astropy/utils/tests/test_introspection.py::test_pkg_finder", "astropy/utils/tests/test_introspection.py::test_find_current_mod", "astropy/utils/tests/test_introspection.py::test_find_mod_objs"] | 848c8fa21332abd66b44efe3cb48b72377fb32cc | 15 min - 1 hour |
astropy/astropy | astropy__astropy-8707 | a85a0747c54bac75e9c3b2fe436b105ea029d6cf | diff --git a/astropy/io/fits/card.py b/astropy/io/fits/card.py
--- a/astropy/io/fits/card.py
+++ b/astropy/io/fits/card.py
@@ -554,6 +554,13 @@ def fromstring(cls, image):
"""
card = cls()
+ if isinstance(image, bytes):
+ # FITS supports only ASCII, but decode as latin1 and just ta... | diff --git a/astropy/io/fits/tests/test_header.py b/astropy/io/fits/tests/test_header.py
--- a/astropy/io/fits/tests/test_header.py
+++ b/astropy/io/fits/tests/test_header.py
@@ -85,6 +85,15 @@ def test_card_constructor_default_args(self):
c = fits.Card()
assert '' == c.keyword
+ def test_card_fr... | ## Issue Description
The `Header.fromstring` method in astropy's FITS handling module fails to accept Python 3 `bytes` objects. While the documentation refers to this method accepting a "byte string" (historically valid for Python 2 where `str` could hold binary data), in Python 3 the distinction between `str` (unicod... | 2019-05-15T13:21:19Z | 3.1 | ["astropy/io/fits/tests/test_header.py::TestHeaderFunctions::test_card_from_bytes"] | ["astropy/io/fits/tests/test_header.py::test_shallow_copy", "astropy/io/fits/tests/test_header.py::test_init_with_header", "astropy/io/fits/tests/test_header.py::test_init_with_dict", "astropy/io/fits/tests/test_header.py::test_init_with_ordereddict", "astropy/io/fits/tests/test_header.py::TestHeaderFunctions::test_ren... | 2e89d074b3b2abc2da80e437c93b1d5516a0ca57 | 15 min - 1 hour | |
astropy/astropy | astropy__astropy-8872 | b750a0e6ee76fb6b8a099a4d16ec51977be46bf6 | diff --git a/astropy/units/quantity.py b/astropy/units/quantity.py
--- a/astropy/units/quantity.py
+++ b/astropy/units/quantity.py
@@ -215,8 +215,8 @@ class Quantity(np.ndarray, metaclass=InheritDocstrings):
dtype : ~numpy.dtype, optional
The dtype of the resulting Numpy array or scalar that will
... | diff --git a/astropy/units/tests/test_quantity.py b/astropy/units/tests/test_quantity.py
--- a/astropy/units/tests/test_quantity.py
+++ b/astropy/units/tests/test_quantity.py
@@ -138,10 +138,13 @@ def test_preserve_dtype(self):
assert q2.value == float(q1.value)
assert q2.unit == q1.unit
- # ... | ## Issue Description
When a `Quantity` object is created from a `numpy.float16` value (e.g., `np.float16(1) * u.km`), the resulting quantity unexpectedly upgrades the data type to `numpy.float64`. This behavior is inconsistent with other floating point types such as `float32`, `float64`, `float128`, and even generic P... | Hmm, it was added in gh-1776 (code in [l299](https://github.com/astropy/astropy/blob/master/astropy/units/quantity.py#L299) and [l379](https://github.com/astropy/astropy/blob/master/astropy/units/quantity.py#L379) by checking `np.can_cast(np.float32, value.dtype)`. From the discussion, it seems half floats were never c... | 2019-06-19T20:34:56Z | 3.1 | ["astropy/units/tests/test_quantity.py::TestQuantityCreation::test_preserve_dtype"] | ["astropy/units/tests/test_quantity.py::TestQuantityCreation::test_1", "astropy/units/tests/test_quantity.py::TestQuantityCreation::test_2", "astropy/units/tests/test_quantity.py::TestQuantityCreation::test_3", "astropy/units/tests/test_quantity.py::TestQuantityCreation::test_nan_inf", "astropy/units/tests/test_quantit... | 2e89d074b3b2abc2da80e437c93b1d5516a0ca57 | 15 min - 1 hour |
django/django | django__django-10554 | 14d026cccb144c6877294ba4cd4e03ebf0842498 | 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
@@ -356,7 +356,12 @@ def get_order_by(self):
resolved.set_source_expressions([RawSQL('%d' % (idx + 1), ())])
br... | diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
--- a/tests/queries/test_qs_combinators.py
+++ b/tests/queries/test_qs_combinators.py
@@ -153,6 +153,29 @@ def test_union_with_values_list_on_annotated_and_unannotated(self):
qs2 = Number.objects.filter(num=9)
sel... | # Union QuerySet with Ordering Breaks During Re-evaluation
## Issue Description
When using Django's `union()` operation on QuerySets with ordering, subsequent operations that modify the ordering (like `.order_by()`) can corrupt the internal SQL generation, leading to a `ProgrammingError` when the QuerySet is re-evalu... | Looks like a bug caused by a .query attribute change without performing a prior copy() of the query/queryset.
Attaching a regression test that fails on master (tested at f3d3338e06d571a529bb2046428eeac8e56bcbf6).
PR
Tests aren't passing.
Needs more tests, at the least. But discussion on PR suggests we've not hit the r... | 2018-10-24T14:24:45Z | 3.0 | ["test_union_with_values_list_and_order (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_union_with_values_list_on_annotated_and_unannotated (queries.test_qs_combinators.QuerySetSetOperationTests)"] | ["test_combining_multiple_models (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_difference (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_intersection (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_union (queries.test_qs_combinators.QuerySetSetOperati... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 1-4 hours |
django/django | django__django-11066 | 4b45b6c8e4d7c9701a332e80d3b1c84209dc36e2 | diff --git a/django/contrib/contenttypes/management/__init__.py b/django/contrib/contenttypes/management/__init__.py
--- a/django/contrib/contenttypes/management/__init__.py
+++ b/django/contrib/contenttypes/management/__init__.py
@@ -24,7 +24,7 @@ def _rename(self, apps, schema_editor, old_model, new_model):
... | diff --git a/tests/contenttypes_tests/test_operations.py b/tests/contenttypes_tests/test_operations.py
--- a/tests/contenttypes_tests/test_operations.py
+++ b/tests/contenttypes_tests/test_operations.py
@@ -14,11 +14,16 @@
),
)
class ContentTypeOperationsTests(TransactionTestCase):
+ databases = {'default', '... | ## Issue Description
The issue occurs in Django's `RenameContentType._rename()` method where a `ContentType` object is saved without specifying the correct database, resulting in it being written to the default database instead of the intended target database. Specifically, the line `content_type.save(update_fields={'... | Added a pull request with the fix. https://github.com/django/django/pull/10332
Hi, I spent all afternoon into this ticket. As I am a newbie I failed to make a test for it. And the fix can really be 'using=db' in the .save() method. But I found a StackOverflow answer about transaction.atomic(using=db) that is interesti... | 2019-03-09T13:03:14Z | 3.0 | ["test_existing_content_type_rename_other_database (contenttypes_tests.test_operations.ContentTypeOperationsTests)"] | ["test_content_type_rename_conflict (contenttypes_tests.test_operations.ContentTypeOperationsTests)", "test_existing_content_type_rename (contenttypes_tests.test_operations.ContentTypeOperationsTests)", "test_missing_content_type_rename_ignore (contenttypes_tests.test_operations.ContentTypeOperationsTests)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-10880 | 838e432e3e5519c5383d12018e6c78f8ec7833c1 | 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
@@ -68,7 +68,7 @@ def get_group_by_cols(self):
return []
def as_sql(self, compiler, connection, **extra_context):
- extra_context['distinct'] = 'D... | diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -8,6 +8,7 @@
Avg, Count, DecimalField, DurationField, F, FloatField, Func, IntegerField,
Max, Min, Sum, Value,
)
+from django.db.models.expressions import Case, When
from... | ## Issue Description
In Django 2.2, using a `Count` annotation with both a `Case` condition and `distinct=True` results in a malformed SQL query due to missing whitespace between the `DISTINCT` keyword and the expression that follows. Specifically, the generated SQL contains patterns like `COUNT(DISTINCTCASE WHEN ...)... | Failing test example
Bisected to [bc05547cd8c1dd511c6b6a6c873a1bc63417b111] Fixed #28658 -- Added DISTINCT handling to the Aggregate class. | 2019-01-21T00:22:36Z | 3.0 | ["test_count_distinct_expression (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... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-10914 | e7fd69d051eaa67cb17f172a39b57253e9cb831a | diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -304,7 +304,7 @@ def gettext_noop(s):
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https:/... | diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1099,7 +1099,7 @@ def test_override_file_upload_permissions(self):
the file_permissions_mode attribute of
django.core.files.storage.default_storage.
"""
- ... | ## Issue Description
When handling file uploads in Django, the final file permissions are inconsistent depending on the upload size and the underlying storage mechanism used. Files uploaded below the `FILE_UPLOAD_MAX_MEMORY_SIZE` threshold are stored in memory using `InMemoryUploadedFile`, while larger files use `Temp... | I think you're talking about ef70af77ec53160d5ffa060c1bdf5ed93322d84f (#28540). I guess the question is whether or not that documentation should be duplicated elsewhere.
Thank you Tim, this is precisely what I was looking for! I can only see one issue with the current docs (if you excuse me for bothering you with such ... | 2019-01-30T13:13:20Z | 3.0 | ["test_override_file_upload_permissions (test_utils.tests.OverrideSettingsTests)"] | ["test_allowed_database_chunked_cursor_queries (test_utils.tests.AllowedDatabaseQueriesTests)", "test_allowed_database_queries (test_utils.tests.AllowedDatabaseQueriesTests)", "test_skip_if_db_feature (test_utils.tests.SkippingTestCase)", "test_skip_unless_db_feature (test_utils.tests.SkippingTestCase)", "test_equal_pa... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-10999 | 36300ef336e3f130a0dadc1143163ff3d23dc843 | diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py
--- a/django/utils/dateparse.py
+++ b/django/utils/dateparse.py
@@ -29,9 +29,10 @@
standard_duration_re = re.compile(
r'^'
r'(?:(?P<days>-?\d+) (days?, )?)?'
- r'((?:(?P<hours>-?\d+):)(?=\d+:\d+))?'
- r'(?:(?P<minutes>-?\d+):)?'
- r'... | diff --git a/tests/utils_tests/test_dateparse.py b/tests/utils_tests/test_dateparse.py
--- a/tests/utils_tests/test_dateparse.py
+++ b/tests/utils_tests/test_dateparse.py
@@ -113,9 +113,12 @@ def test_negative(self):
test_values = (
('-4 15:30', timedelta(days=-4, minutes=15, seconds=30)),
... | ## Issue Description
The Django utility function `parse_duration()` in `django/utils/dateparse.py` fails to correctly parse certain **negative duration strings** due to a flaw in its primary regex pattern: `standard_duration_re`.
This regex defines how to parse duration strings like `"1 02:03:04"` or `"-1:02:03"`. Al... | Please give an example valid that's not working. There are some tests for negative values.
Right, this should have been fixed by #27699 which is included in 1.11.x.
Example cases, can be discussed: parse_duration('-00:01:01') => plus 61 seconds, so it is not -(00:01:01) but (-00):(+01):(+01) parse_duration('00:-01:-01... | 2019-02-16T07:44:50Z | 3.0 | ["test_negative (utils_tests.test_dateparse.DurationParseTests)", "test_parse_postgresql_format (utils_tests.test_dateparse.DurationParseTests)"] | ["test_parse_date (utils_tests.test_dateparse.DateParseTests)", "test_parse_datetime (utils_tests.test_dateparse.DateParseTests)", "test_parse_time (utils_tests.test_dateparse.DateParseTests)", "test_days (utils_tests.test_dateparse.DurationParseTests)", "test_fractions_of_seconds (utils_tests.test_dateparse.DurationPa... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-10097 | b9cf764be62e77b4777b3a75ec256f6209a57671 | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -94,7 +94,7 @@ class URLValidator(RegexValidator):
regex = _lazy_re_compile(
r'^(?:[a-z0-9\.\-\+]*)://' # scheme is validated separately
- r'(?:\S+(?::\S*)?@)?' ... | diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
--- a/tests/validators/invalid_urls.txt
+++ b/tests/validators/invalid_urls.txt
@@ -57,3 +57,9 @@ http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | ## Issue Description
The current implementation of Django’s `URLValidator` accepts URLs with invalid characters in the username and password fields of the authority component (userinfo), according to RFC 1738 section 3.1. Specifically, the characters `:`, `@`, and `/` **must be percent-encoded** when present in the us... | 2018-06-26T23:30:51Z | 2.2 | ["test_ascii_validator (auth_tests.test_validators.UsernameValidatorsTests)", "test_unicode_validator (auth_tests.test_validators.UsernameValidatorsTests)", "test_help_text (auth_tests.test_validators.UserAttributeSimilarityValidatorTest)", "test_validate (auth_tests.test_validators.UserAttributeSimilarityValidatorTest... | ["test_defaults (str.tests.SimpleTests)", "test_international (str.tests.SimpleTests)", "test_default (model_fields.test_decimalfield.DecimalFieldTests)", "test_filter_with_strings (model_fields.test_decimalfield.DecimalFieldTests)", "test_get_prep_value (model_fields.test_decimalfield.DecimalFieldTests)", "test_lookup... | 4fc35a9c3efdc9154efce28cb23cb84f8834517e | <15 min fix | |
django/django | django__django-10973 | ddb293685235fd09e932805771ae97f72e817181 | diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -2,17 +2,9 @@
import signal
import subprocess
-from django.core.files.temp import NamedTemporaryFile
from django.db.backends.... | diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py
--- a/tests/dbshell/test_postgresql.py
+++ b/tests/dbshell/test_postgresql.py
@@ -1,5 +1,6 @@
import os
import signal
+import subprocess
from unittest import mock
from django.db.backends.postgresql.client import DatabaseClient
@@ -11... | ## Issue Description
The issue involves optimizing the use of `subprocess` in the PostgreSQL database backend client implementation within Django. Currently, the code for launching PostgreSQL CLI tools (e.g., `psql`) uses `subprocess.Popen` — a lower-level and more verbose API — when setting up the process with envir... | 2019-02-11T01:19:56Z | 3.0 | ["test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_column (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_nopass (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "SIGINT is ignored in Py... | [] | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour | |
django/django | django__django-11095 | 7d49ad76562e8c0597a0eb66046ab423b12888d8 | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -327,6 +327,10 @@ def get_fieldsets(self, request, obj=None):
return self.fieldsets
return [(None, {'fields': self.get_fields(request, obj)}... | diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -429,3 +429,29 @@ class EpisodeAdmin(admin.ModelAdmin):
inlines = ma.get_inline_instances(request)
for (formset, inline), other_... | ## Issue Description
Django’s `ModelAdmin` class currently allows developers to define inlines statically via the `inlines` attribute. However, there is no clean hook for dynamically determining which inlines should be displayed based on the current request or the model instance being edited. While it's possible to ov... | Are you going to offer a patch to show exactly what you have in mind? I'm not immediately convinced that another hook is needed since the cost of duplicating a for loop is not that great.
If I want to realize a dynamic inlines based on the request or model instance. I need to override get_inline_instances to do it. Wha... | 2019-03-19T15:17:28Z | 3.0 | ["test_get_inline_instances_override_get_inlines (generic_inline_admin.tests.GenericInlineModelAdminTest)"] | ["test_no_deletion (generic_inline_admin.tests.NoInlineDeletionTest)", "test_custom_form_meta_exclude (generic_inline_admin.tests.GenericInlineModelAdminTest)", "test_custom_form_meta_exclude_with_readonly (generic_inline_admin.tests.GenericInlineModelAdminTest)", "test_get_fieldsets (generic_inline_admin.tests.Generic... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11087 | 8180ffba21bf10f4be905cb0d4890dc2bcff2788 | diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -1,4 +1,5 @@
from collections import Counter
+from itertools import chain
from operator import attrgetter
from django.db import IntegrityError, connections, transaction
... | diff --git a/tests/delete/models.py b/tests/delete/models.py
--- a/tests/delete/models.py
+++ b/tests/delete/models.py
@@ -126,3 +126,20 @@ class Base(models.Model):
class RelToBase(models.Model):
base = models.ForeignKey(Base, models.DO_NOTHING)
+
+
+class Origin(models.Model):
+ pass
+
+
+class Referrer(mo... | # Enhanced Problem Statement: UnicodeDecodeError During `.delete()` in Django ORM After Python 2 to 3 Migration
## Issue Description
This issue occurs during a Django 1.11 to Python 3.6 upgrade when executing the `.delete()` method on model instances containing non-UTF-8 compliant data that was stored under Python 2.... | I think this would have been better posted elsewhere. See TicketClosingReasons/UseSupportChannels. However... Create some instances: >>> Group.objects.create(name="a") INSERT INTO "auth_group" ("name") VALUES ('a') RETURNING "auth_group"."id"; args=('a',) [utils.py:111] <Group: a> >>> Group.objects.create(name="b") INS... | 2019-03-16T22:59:57Z | 3.0 | ["test_only_referenced_fields_selected (delete.tests.DeletionTests)"] | ["test_fast_delete_empty_no_update_can_self_select (delete.tests.FastDeleteTests)", "test_fast_delete_fk (delete.tests.FastDeleteTests)", "test_fast_delete_inheritance (delete.tests.FastDeleteTests)", "test_fast_delete_instance_set_pk_none (delete.tests.FastDeleteTests)", "test_fast_delete_joined_qs (delete.tests.FastD... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11099 | d26b2424437dabeeca94d7900b37d2df4410da0c | diff --git a/django/contrib/auth/validators.py b/django/contrib/auth/validators.py
--- a/django/contrib/auth/validators.py
+++ b/django/contrib/auth/validators.py
@@ -7,7 +7,7 @@
@deconstructible
class ASCIIUsernameValidator(validators.RegexValidator):
- regex = r'^[\w.@+-]+$'
+ regex = r'^[\w.@+-]+\Z'
m... | diff --git a/tests/auth_tests/test_validators.py b/tests/auth_tests/test_validators.py
--- a/tests/auth_tests/test_validators.py
+++ b/tests/auth_tests/test_validators.py
@@ -237,7 +237,7 @@ def test_unicode_validator(self):
invalid_usernames = [
"o'connell", "عبد ال",
"zerowidth\u200... | ## Issue Description
The `ASCIIUsernameValidator` and `UnicodeUsernameValidator` in Django's `contrib.auth.validators` module incorrectly allow usernames that end with a newline character (`\n`). This issue arises due to a common Python regex quirk: the `$` anchor in their regex pattern — `r'^[\w.@+-]+$'` — matches **... | 2019-03-20T03:46:18Z | 3.0 | ["test_ascii_validator (auth_tests.test_validators.UsernameValidatorsTests)", "test_unicode_validator (auth_tests.test_validators.UsernameValidatorsTests)", "test_help_text (auth_tests.test_validators.UserAttributeSimilarityValidatorTest)"] | ["test_help_text (auth_tests.test_validators.MinimumLengthValidatorTest)", "test_validate (auth_tests.test_validators.MinimumLengthValidatorTest)", "test_help_text (auth_tests.test_validators.NumericPasswordValidatorTest)", "test_validate (auth_tests.test_validators.NumericPasswordValidatorTest)", "test_validate (auth_... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11119 | d4df5e1b0b1c643fe0fc521add0236764ec8e92a | diff --git a/django/template/engine.py b/django/template/engine.py
--- a/django/template/engine.py
+++ b/django/template/engine.py
@@ -160,7 +160,7 @@ def render_to_string(self, template_name, context=None):
if isinstance(context, Context):
return t.render(context)
else:
- retu... | diff --git a/tests/template_tests/test_engine.py b/tests/template_tests/test_engine.py
--- a/tests/template_tests/test_engine.py
+++ b/tests/template_tests/test_engine.py
@@ -21,6 +21,13 @@ def test_basic_context(self):
'obj:test\n',
)
+ def test_autoescape_off(self):
+ engine = Engine... | # Issue Description
The `Engine.render_to_string()` method in Django's template engine does not honor the `autoescape` attribute configured on the `Engine` instance. When an `Engine` is initialized with `autoescape=False`, calling `render_to_string()` still applies autoescaping to the rendered template output.
This o... | I'd like to reserve this for an event I'll attend on Oct 4th. | 2019-03-24T21:17:05Z | 3.0 | ["test_autoescape_off (template_tests.test_engine.RenderToStringTest)"] | ["test_cached_loader_priority (template_tests.test_engine.LoaderTests)", "test_loader_priority (template_tests.test_engine.LoaderTests)", "test_origin (template_tests.test_engine.LoaderTests)", "test_basic_context (template_tests.test_engine.RenderToStringTest)", "test_multiple_engines_configured (template_tests.test_e... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11133 | 879cc3da6249e920b8d54518a0ae06de835d7373 | diff --git a/django/http/response.py b/django/http/response.py
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -229,7 +229,7 @@ def make_bytes(self, value):
# Handle string types -- we can't rely on force_bytes here because:
# - Python attempts str conversion first
# - when sel... | diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -366,6 +366,10 @@ def test_non_string_content(self):
r.content = 12345
self.assertEqual(r.content, b'12345')
+ def test_memoryview_content(self):
+ ... | ## Issue Description
The `HttpResponse` class in Django fails to correctly handle `memoryview` objects, which are commonly returned by PostgreSQL when querying `BinaryField` data. Instead of converting the `memoryview` to its underlying byte representation, `HttpResponse` treats it as a generic Python object and rende... | I guess HttpResponseBase.make_bytes could be adapted to deal with memoryview objects by casting them to bytes. In all cases simply wrapping the memoryview in bytes works as a workaround HttpResponse(bytes(model.binary_field)).
The fact make_bytes would still use force_bytes if da56e1bac6449daef9aeab8d076d2594d9fd5b44 ... | 2019-03-27T06:48:09Z | 3.0 | ["test_memoryview_content (httpwrappers.tests.HttpResponseTests)"] | ["test_streaming_response (httpwrappers.tests.StreamingHttpResponseTests)", "test_cookie_edgecases (httpwrappers.tests.CookieTests)", "Semicolons and commas are decoded.", "Semicolons and commas are encoded.", "test_httponly_after_load (httpwrappers.tests.CookieTests)", "test_invalid_cookies (httpwrappers.tests.CookieT... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11138 | c84b91b7603e488f7171fdff8f08368ef3d6b856 | diff --git a/django/db/backends/mysql/operations.py b/django/db/backends/mysql/operations.py
--- a/django/db/backends/mysql/operations.py
+++ b/django/db/backends/mysql/operations.py
@@ -69,8 +69,8 @@ def date_trunc_sql(self, lookup_type, field_name):
return "DATE(%s)" % (field_name)
def _convert_fi... | diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
--- a/tests/timezones/tests.py
+++ b/tests/timezones/tests.py
@@ -47,6 +47,26 @@
ICT = timezone.get_fixed_timezone(420) # Asia/Bangkok
+@contextmanager
+def override_database_connection_timezone(timezone):
+ try:
+ orig_timezone = conn... | # Django Date Lookup Timezone Handling Issue in MySQL, SQLite, and Oracle
## Issue Description
When using Django's `__date` lookup on timezone-aware datetime fields, the database-specific `TIME_ZONE` setting in `DATABASES` configuration is ignored, causing incorrect filtering behavior. This affects MySQL, SQLite, and... | Opened a pull request on github with a quick fix, it's tested but lacks a TestCase https://github.com/django/django/pull/8714
Looks reasonable at a brief review.
PR | 2019-03-28T13:11:56Z | 3.0 | ["test_query_convert_timezones (timezones.tests.NewDatabaseTests)"] | ["test_aware_datetime_in_utc (timezones.tests.SerializationTests)", "test_naive_datetime (timezones.tests.SerializationTests)", "test_naive_datetime_with_microsecond (timezones.tests.SerializationTests)", "test_auto_now_and_auto_now_add (timezones.tests.LegacyDatabaseTests)", "test_aware_datetime_unsupported (timezones... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 1-4 hours |
django/django | django__django-11149 | e245046bb6e8b32360aa48b8a41fb7050f0fc730 | 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
@@ -2111,46 +2111,50 @@ def get_queryset(self, request):
queryset = queryset.none()
return queryset
+ def _has_any_perms_for_target_model(... | diff --git a/tests/admin_inlines/models.py b/tests/admin_inlines/models.py
--- a/tests/admin_inlines/models.py
+++ b/tests/admin_inlines/models.py
@@ -37,6 +37,9 @@ def __str__(self):
class Book(models.Model):
name = models.CharField(max_length=50)
+ def __str__(self):
+ return self.name
+
class Au... | ## Issue Description
In Django admin, when using inlines for auto-created `ManyToManyField`s (`TabularInline` or `StackedInline`), the inline forms are incorrectly **editable** even when the user only has **view permissions** for the related model. This represents a regression from expected behavior where users with o... | OK, yes. Fleshing it out I can reproduce this against 2.1.7 with the models and inline provided. A user with only the view permission for both Report and Photo can edit the M2M in the inline. When the M2M is handled as a normal field, rather than an inline, the behaviour is correct. Elevating to a Release Blocker as a ... | 2019-03-30T18:14:35Z | 3.0 | ["test_inline_add_m2m_view_only_perm (admin_inlines.tests.TestInlinePermissions)", "test_inline_change_m2m_view_only_perm (admin_inlines.tests.TestInlinePermissions)"] | ["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... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11141 | 5d9cf79baf07fc4aed7ad1b06990532a65378155 | diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
--- a/django/db/migrations/loader.py
+++ b/django/db/migrations/loader.py
@@ -84,11 +84,6 @@ def load_disk(self):
continue
raise
else:
- # Empty directories are namespaces.
- ... | diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -508,6 +508,17 @@ def test_ignore_files(self):
migrations = [name for app, name in loader.disk_migrations if app == 'migrations']
self.assertEqu... | # Enhanced Problem Statement: Allow Migrations Directories Without `__init__.py` Files
## Issue Description
Django's migration system currently fails when attempting to run migrations on directories that lack `__init__.py` files (Python 3 implicit namespace packages). This occurs because the system checks for the `__... | 2019-03-28T20:49:53Z | 3.1 | ["Migration directories without an __init__.py file are loaded."] | ["test_apply (migrations.test_loader.RecorderTests)", "test_invalid (migrations.test_loader.PycLoaderTests)", "test_valid (migrations.test_loader.PycLoaderTests)", "test_check_consistent_history (migrations.test_loader.LoaderTests)", "test_check_consistent_history_squashed (migrations.test_loader.LoaderTests)", "test_e... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-11163 | e6588aa4e793b7f56f4cadbfa155b581e0efc59a | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -83,7 +83,7 @@ def model_to_dict(instance, fields=None, exclude=None):
for f in chain(opts.concrete_fields, opts.private_fields, opts.many_to_many):
if not getattr(f, 'editable', False... | diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -1814,6 +1814,10 @@ class Meta:
bw = BetterWriter.objects.create(name='Joe Better', score=10)
self.assertEqual(sorted(model_to_dict(bw)), ['id', 'name', 'score', ... | # Enhanced Problem Statement: `model_to_dict()` Should Return Empty Dict for Empty Fields List
## Issue Description
The Django utility function `model_to_dict()` contains a logic flaw in its field filtering mechanism. When called as `model_to_dict(instance, fields=[])`, it should return an empty dictionary since no f... | model_to_dict() is a part of private API. Do you have any real use case for passing empty list to this method?
PR
This method is comfortable to fetch instance fields values without touching ForeignKey fields. List of fields to be fetched is an attr of the class, which can be overridden in subclasses and is empty list ... | 2019-04-02T21:46:42Z | 3.0 | ["test_modelform_subclassed_model (model_forms.tests.ModelOneToOneFieldTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "test_setattr_raises_validation_error_field_specific (model_forms.tests.StrictAssignmentTests)", "test_setattr_raises_validation_error_non_field (model_forms.tests.StrictAssignmentTests)", "test_notrequired_overrides_notblank (model_forms.... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11179 | 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_... | # Enhanced Problem Statement
## Issue Description
When calling `delete()` on Django model instances that have no dependencies (i.e., no other objects referencing them via foreign keys), the primary key (PK) value is not being cleared from the in-memory model instance. After a successful deletion, the PK should be set... | 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 | <15 min fix |
django/django | django__django-11239 | d87bd29c4f8dfcdf3f4a4eb8340e6770a2416fe3 | diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -17,6 +17,10 @@ def runshell_db(cls, conn_params):
dbname = conn_params.get('database', '')
user = conn_params.g... | diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py
--- a/tests/dbshell/test_postgresql.py
+++ b/tests/dbshell/test_postgresql.py
@@ -14,15 +14,16 @@ def _run_it(self, dbinfo):
That function invokes the runshell command, while mocking
subprocess.run(). It returns a 2-tuple... | ## Issue Description
Currently, Django’s PostgreSQL backend supports mutual TLS (mTLS) authentication using `sslmode`, `sslrootcert`, `sslcert`, and `sslkey` within the `DATABASES['OPTIONS']` configuration. This allows secure connections to the database using client-side certificates.
However, **the `dbshell` managem... | 2019-04-16T09:44:54Z | 3.0 | ["test_ssl_certificate (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)"] | ["test_accent (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_basic (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_column (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "test_nopass (dbshell.test_postgresql.PostgreSqlDbshellCommandTestCase)", "SIGINT is ignored in Py... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11211 | ba726067604ce5a8ca3919edf653496722b433ab | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -2325,6 +2325,10 @@ def deconstruct(self):
def get_internal_type(self):
return "UUIDField"
+ def get_prep_value(self, value):
+... | diff --git a/tests/prefetch_related/models.py b/tests/prefetch_related/models.py
--- a/tests/prefetch_related/models.py
+++ b/tests/prefetch_related/models.py
@@ -172,6 +172,11 @@ def __str__(self):
return self.tag
+class Article(models.Model):
+ id = models.UUIDField(primary_key=True, default=uuid.uuid... | # Prefetch Related Not Working with Generic Foreign Key to UUID Primary Key
## Issue Description
When using Django's `prefetch_related()` with a GenericForeignKey (GFK) that references a model with a UUID primary key, the prefetched attribute returns `None` instead of the related object. This occurs because Django's ... | Thanks for the report, however GenericForeignKey doesn't support prefetch_related(), from the same reason it doesn't not support also filter(), exclude(), etc. Please see documentation. | 2019-04-13T12:01:14Z | 3.0 | ["test_prefetch_GFK_uuid_pk (prefetch_related.tests.GenericRelationTests)"] | ["test_bug (prefetch_related.tests.Ticket21410Tests)", "test_basic (prefetch_related.tests.RawQuerySetTests)", "test_clear (prefetch_related.tests.RawQuerySetTests)", "test_prefetch_before_raw (prefetch_related.tests.RawQuerySetTests)", "test_bug (prefetch_related.tests.Ticket19607Tests)", "test_m2m_then_m2m (prefetch_... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11206 | 571ab44e8a8936014c22e7eebe4948d9611fd7ce | diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
--- a/django/utils/numberformat.py
+++ b/django/utils/numberformat.py
@@ -27,6 +27,14 @@ def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
# sign
sign = ''
if isinstance(number, Decimal):
+
+ if d... | diff --git a/tests/utils_tests/test_numberformat.py b/tests/utils_tests/test_numberformat.py
--- a/tests/utils_tests/test_numberformat.py
+++ b/tests/utils_tests/test_numberformat.py
@@ -94,7 +94,7 @@ def test_decimal_numbers(self):
('1e-10', 8, '0.00000000'),
('1e-11', 8, '0.00000000'),
... | ## Issue Description
When formatting extremely small `Decimal` values (e.g., `1e-200`) using `django.utils.numberformat.format` (or the related `django.utils.formats.number_format`), numbers smaller than the specified `decimal_pos` precision are rendered in exponential notation instead of being coerced to zero in fixe... | Hi Sjoerd. OK, so this is related to the changes in 9cc6a60040b0f64f8ea066dd215176d4bd16621d. Happy to Accept as a potential Cleanup/optimization — I guess ultimately it depends on what the change looks like. (i.e. is the nicer behaviour worth the extra complexity? etc) I'm assuming you're ready/willing to make the pat... | 2019-04-13T10:19:38Z | 3.0 | ["test_decimal_numbers (utils_tests.test_numberformat.TestNumberFormat)", "test_decimal_subclass (utils_tests.test_numberformat.TestNumberFormat)"] | ["test_float_numbers (utils_tests.test_numberformat.TestNumberFormat)", "test_format_number (utils_tests.test_numberformat.TestNumberFormat)", "test_format_string (utils_tests.test_numberformat.TestNumberFormat)", "test_large_number (utils_tests.test_numberformat.TestNumberFormat)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11265 | 21aa2a5e785eef1f47beb1c3760fdd7d8915ae09 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1666,6 +1666,7 @@ def split_exclude(self, filter_expr, can_reuse, names_with_path):
filter_expr = (filter_lhs, OuterRef(filter_rhs.name))
# Generat... | diff --git a/tests/filtered_relation/tests.py b/tests/filtered_relation/tests.py
--- a/tests/filtered_relation/tests.py
+++ b/tests/filtered_relation/tests.py
@@ -98,6 +98,14 @@ def test_with_join(self):
[self.author1]
)
+ def test_with_exclude(self):
+ self.assertSequenceEqual(
+ ... | # Comprehensive Problem Statement: Exclude with Annotated FilteredRelation Raises FieldError
## Issue Description
When using Django's `exclude()` method on a QuerySet that has been annotated with a `FilteredRelation`, a `FieldError` is raised indicating that the annotated field name cannot be resolved. This occurs be... | I've submitted a PR: PR
Patch looks good but it looks like doesn't qualify for a backport given FilteredRelation was introduced in Django 2.0 and isn't considered a new feature at this point.
Hi, i've tested the solution you're giving in your PR but it doesn't seams to be ok, let me explain. Even if the error is not t... | 2019-04-21T12:57:28Z | 3.0 | ["test_with_exclude (filtered_relation.tests.FilteredRelationTests)"] | ["test_aggregate (filtered_relation.tests.FilteredRelationAggregationTests)", "test_as_subquery (filtered_relation.tests.FilteredRelationTests)", "test_defer (filtered_relation.tests.FilteredRelationTests)", "test_difference (filtered_relation.tests.FilteredRelationTests)", "test_exclude_relation_with_join (filtered_re... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11292 | eb16c7260e573ec513d84cb586d96bdf508f3173 | 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
@@ -95,7 +95,7 @@ class DjangoHelpFormatter(HelpFormatter):
"""
show_last = {
'--version', '--verbosity', '--traceback', '--settings', '--pythonpath',... | 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
@@ -253,6 +253,16 @@ def test_disallowed_abbreviated_options(self):
self.assertNoOutput(err)
self.assertEqual(out.strip(), 'Set foo')
+ def test_skip_chec... | ## Issue Description
Django management commands currently support a **stealth (undocumented) `--skip-checks` option** that allows system checks to be bypassed during command execution. This functionality already exists internally but is not exposed as a public CLI argument. The goal of this issue is to **officially ex... | 2019-04-27T14:23:07Z | 3.0 | ["test_skip_checks (user_commands.tests.CommandRunTests)"] | ["test_get_random_secret_key (user_commands.tests.UtilsTests)", "test_is_ignored_path_false (user_commands.tests.UtilsTests)", "test_is_ignored_path_true (user_commands.tests.UtilsTests)", "test_no_existent_external_program (user_commands.tests.UtilsTests)", "test_normalize_path_patterns_truncates_wildcard_base (user_c... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour | |
django/django | django__django-11276 | 28d5262fa3315690395f04e3619ed554dbaf725b | diff --git a/django/utils/html.py b/django/utils/html.py
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -1,5 +1,6 @@
"""HTML utilities suitable for global use."""
+import html
import json
import re
from html.parser import HTMLParser
@@ -24,14 +25,6 @@
simple_url_re = re.compile(r'^https?://\[?\w', re.I... | diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py
--- a/tests/admin_docs/test_views.py
+++ b/tests/admin_docs/test_views.py
@@ -199,7 +199,7 @@ def test_methods_with_arguments_display_arguments_default_value(self):
"""
Methods with keyword arguments should have their argumen... | ## Issue Description
The current implementation of `django.utils.html.escape()` duplicates functionality already provided by Python's standard library function `html.escape()`, which has been available since Python 3.2. The Django version is less performant than the standard library equivalent, and this discrepancy be... | 2019-04-24T12:35:05Z | 3.0 | ["test_make_list02 (template_tests.filter_tests.test_make_list.MakeListTests)", "test_password_help_text (auth_tests.test_forms.UserCreationFormTest)", "test_url_split_chars (template_tests.filter_tests.test_urlize.FunctionTests)", "test_wrapping_characters (template_tests.filter_tests.test_urlize.FunctionTests)", "tes... | ["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)", "test_password_whitespace_not_stripped (auth_tests.test_forms.AdminPasswordChangeForm... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour | |
django/django | django__django-11400 | 1f8382d34d54061eddc41df6994e20ee38c60907 | diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
--- a/django/contrib/admin/filters.py
+++ b/django/contrib/admin/filters.py
@@ -193,11 +193,17 @@ def has_output(self):
def expected_parameters(self):
return [self.lookup_kwarg, self.lookup_kwarg_isnull]
- def field_choice... | diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py
--- a/tests/admin_filters/tests.py
+++ b/tests/admin_filters/tests.py
@@ -591,6 +591,22 @@ class BookAdmin(ModelAdmin):
expected = [(self.john.pk, 'John Blue'), (self.jack.pk, 'Jack Red')]
self.assertEqual(filterspec.lookup_choic... | # Django Admin ListFilter Ordering Issue
## Issue Description
The Django admin interface's filtering system does not properly respect model-level ordering configurations for related fields. Specifically:
1. **RelatedFieldListFilter** fails to fall back to the ordering defined in the related model's `Meta.ordering` w... | Sample project illustrating the problem. Navigate to /admin/foo/book and observer the order of Author in the list filters.
Screenshot of RelatedOnlyFieldListFilter not ordering items.
OK, yes, seems a reasonable suggestion if you'd like to work on it.
Hello. We've updated our django recently and faced this bug. For me ... | 2019-05-22T11:30:39Z | 3.0 | ["test_get_choices_default_ordering (model_fields.tests.GetChoicesOrderingTests)", "test_get_choices_reverse_related_field_default_ordering (model_fields.tests.GetChoicesOrderingTests)", "RelatedFieldListFilter ordering respects Model.ordering.", "test_relatedfieldlistfilter_reverse_relationships_default_ordering (admi... | ["test_choices_and_field_display (model_fields.tests.GetFieldDisplayTests)", "test_empty_iterator_choices (model_fields.tests.GetFieldDisplayTests)", "A translated display value is coerced to str.", "test_iterator_choices (model_fields.tests.GetFieldDisplayTests)", "test_check (model_fields.tests.ChoicesTests)", "test_... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 1-4 hours |
django/django | django__django-11333 | 55b68de643b5c2d5f0a8ea7587ab3b2966021ccc | diff --git a/django/urls/base.py b/django/urls/base.py
--- a/django/urls/base.py
+++ b/django/urls/base.py
@@ -7,7 +7,7 @@
from django.utils.translation import override
from .exceptions import NoReverseMatch, Resolver404
-from .resolvers import get_ns_resolver, get_resolver
+from .resolvers import _get_cached_resol... | diff --git a/tests/urlpatterns/test_resolvers.py b/tests/urlpatterns/test_resolvers.py
--- a/tests/urlpatterns/test_resolvers.py
+++ b/tests/urlpatterns/test_resolvers.py
@@ -1,5 +1,6 @@
from django.test import SimpleTestCase
-from django.urls.resolvers import RegexPattern, RoutePattern
+from django.test.utils import ... | ## Issue Description
Django’s `django.urls.resolvers.get_resolver` function can inadvertently construct multiple instances of `URLResolver`, especially when called both before and after a request is processed. This results in redundant and expensive calls to `URLResolver._populate()`, which builds internal routing cac... | I'm planning to contribute a fix, as soon as I can get the CLA signed. Hi. Great. Happy to provisionally Accept this pending how the patch looks. (Sounds fine in principle.) Welcome on-board! :) | 2019-05-06T21:00:53Z | 3.0 | ["test_resolver_cache_default__root_urlconf (urlpatterns.test_resolvers.ResolverCacheTests)"] | ["test_str (urlpatterns.test_resolvers.RegexPatternTests)", "test_str (urlpatterns.test_resolvers.RoutePatternTests)"] | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11433 | 21b1d239125f1228e579b1ce8d94d4d5feadd2a6 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -48,8 +48,11 @@ def construct_instance(form, instance, fields=None, exclude=None):
continue
# Leave defaults for fields that aren't in POST data, except for
# checkbox... | diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -585,6 +585,32 @@ class Meta:
m2 = mf2.save(commit=False)
self.assertEqual(m2.mode, '')
+ def test_default_not_populated_on_non_empty_value_in_cleaned_data(sel... | # Allow `cleaned_data` to Overwrite Model Field Defaults in Django Forms
## Issue Description
When a Django `ModelForm` processes form data, any field that is **not included in the submitted form payload** but **has a default value defined on the model** cannot be overwritten by modifications to `form.cleaned_data`. ... | 2019-05-31T17:06:20Z | 3.0 | ["test_default_not_populated_on_non_empty_value_in_cleaned_data (model_forms.tests.ModelFormBaseTest)"] | ["test_model_form_clean_applies_to_model (model_forms.tests.CustomCleanTests)", "test_override_clean (model_forms.tests.CustomCleanTests)", "test_model_form_applies_localize_to_all_fields (model_forms.tests.LocalizedModelFormTest)", "test_model_form_applies_localize_to_some_fields (model_forms.tests.LocalizedModelFormT... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11299 | 6866c91b638de5368c18713fa851bfe56253ea55 | 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
@@ -1338,7 +1338,7 @@ def _add_q(self, q_object, used_aliases, branch_negated=False,
if isinstance(child, Node):
child_clause, needed_inner = s... | 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
@@ -1898,6 +1898,29 @@ def test_add_constraint_percent_escaping(self):
author = Author.objects.create(name='Albert', rebate='10%')
... | ## Issue Description
In Django, when defining a `CheckConstraint` with a logical combination of conditions using both `AND` and `OR` operators (e.g., `Q(flag=True, field_1__isnull=False) | Q(flag=False)`), the generated SQL for the constraint improperly includes **fully qualified column names** like `"new__app_testcon... | Could you confirm this also happens on other backends than SQLite?
PR
The patch changes are looking great. I left a suggestion to simply one the tests assertions to make them easier to parse by a human but they are testing the right thing. | 2019-04-28T11:15:08Z | 3.0 | ["test_simplecol_query (queries.test_query.TestQuery)"] | ["test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.FieldOperationTests)", "test_references_field_by_remote_field_model (migrations.... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11451 | e065b293878b1e3ea56655aa9d33e87576cd77ff | diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
--- a/django/contrib/auth/backends.py
+++ b/django/contrib/auth/backends.py
@@ -39,6 +39,8 @@ class ModelBackend(BaseBackend):
def authenticate(self, request, username=None, password=None, **kwargs):
if username is None:
... | diff --git a/tests/auth_tests/test_auth_backends.py b/tests/auth_tests/test_auth_backends.py
--- a/tests/auth_tests/test_auth_backends.py
+++ b/tests/auth_tests/test_auth_backends.py
@@ -226,6 +226,19 @@ def test_authentication_timing(self):
authenticate(username='no_such_user', password='test')
self.... | # Enhanced Problem Statement: ModelBackend.authenticate() Should Early-Exit When Username or Password Is None
## Issue Description
The `ModelBackend.authenticate()` method in Django's authentication system performs unnecessary database queries and expensive password hashing operations when called with `username=None` ... | 2019-06-08T19:11:42Z | 3.0 | ["test_authentication_without_credentials (auth_tests.test_auth_backends.ModelBackendTest)", "test_custom_perms (auth_tests.test_auth_backends.ModelBackendTest)", "test_authentication_without_credentials (auth_tests.test_auth_backends.CustomPermissionsUserModelBackendTest)", "test_custom_perms (auth_tests.test_auth_bac... | ["test_raises_exception (auth_tests.test_auth_backends.NoBackendsTest)", "test_get_all_permissions (auth_tests.test_auth_backends.BaseBackendTest)", "test_get_group_permissions (auth_tests.test_auth_backends.BaseBackendTest)", "test_get_user_permissions (auth_tests.test_auth_backends.BaseBackendTest)", "test_has_perm (... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11477 | e28671187903e6aca2428374fdd504fca3032aee | diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -153,7 +153,7 @@ def match(self, path):
# If there are any named groups, use those as kwargs, ignoring
# non-named groups. Otherwise, pass all non-named arguments a... | diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -158,6 +158,15 @@ def test_translate_url_utility(self):
# path() URL pattern
self.assertEqual(translate_url('/en/account/register-as-path/', 'nl'), ... | # Enhanced Problem Statement
## Issue Description
The `translate_url()` function in Django produces malformed URLs when URL patterns contain optional named groups that are not provided during URL generation. This issue occurs specifically when route patterns include optional components using bracket notation (e.g., `... | Could you please provide the patch as a pull request against master? Unless this is a regression, it probably doesn't qualify for a backport to 1.9 (see our supported versions policy). Please check the patch on Python 3 as well (dict.iteritems() doesn't exist there).
The issue here is that resolve() will return None f... | 2019-06-14T17:40:45Z | 3.0 | ["test_re_path_with_optional_parameter (urlpatterns.tests.SimplifiedURLTests)", "test_two_variable_at_start_of_path_pattern (urlpatterns.tests.SimplifiedURLTests)", "test_translate_url_utility (i18n.patterns.tests.URLTranslationTests)"] | ["test_include_2_tuple (urlpatterns_reverse.tests.IncludeTests)", "test_include_2_tuple_namespace (urlpatterns_reverse.tests.IncludeTests)", "test_include_3_tuple (urlpatterns_reverse.tests.IncludeTests)", "test_include_3_tuple_namespace (urlpatterns_reverse.tests.IncludeTests)", "test_include_4_tuple (urlpatterns_reve... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11490 | a7038adbd02c916315b16939b835f021c2ee8880 | 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
@@ -426,6 +426,7 @@ def get_combinator_sql(self, combinator, all):
# must have the same columns list. Set the selects defined on
... | diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
--- a/tests/queries/test_qs_combinators.py
+++ b/tests/queries/test_qs_combinators.py
@@ -123,6 +123,9 @@ def test_union_with_values(self):
self.assertEqual(reserved_name['order'], 2)
reserved_name = qs1.union(qs1... | ## Issue Description
In Django, when constructing **composed database queries**—such as those created using `union()`, `intersection()`, or `difference()`—subsequent calls to `.values()` or `.values_list()` with **different field selections** are incorrectly ignored. Instead of regenerating the query with the new colu... | 2019-06-19T07:47:46Z | 3.0 | ["test_union_with_values (queries.test_qs_combinators.QuerySetSetOperationTests)"] | ["test_combining_multiple_models (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_difference (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_intersection (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_union (queries.test_qs_combinators.QuerySetSetOperati... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix | |
django/django | django__django-11532 | a5308514fb4bc5086c9a16a8a24a945eeebb073c | diff --git a/django/core/mail/message.py b/django/core/mail/message.py
--- a/django/core/mail/message.py
+++ b/django/core/mail/message.py
@@ -16,7 +16,7 @@
from django.conf import settings
from django.core.mail.utils import DNS_NAME
-from django.utils.encoding import force_str
+from django.utils.encoding import fo... | diff --git a/tests/mail/tests.py b/tests/mail/tests.py
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -14,10 +14,11 @@
from io import StringIO
from smtplib import SMTP, SMTPAuthenticationError, SMTPException
from ssl import SSLError
+from unittest import mock
from django.core import mail
from django.core... | # Comprehensive Problem Statement
## Issue Description
Django crashes when sending emails on systems where the hostname contains non-ASCII characters (e.g., "正宗") and the email encoding is set to a non-Unicode charset like `iso-8859-1`. The crash occurs during Message-ID header generation when Django attempts to encod... | Thanks for the report. Simple encoding should fix this issue, e.g. diff --git a/django/core/mail/utils.py b/django/core/mail/utils.py index d18dfe4667..68f9e464d6 100644 --- a/django/core/mail/utils.py +++ b/django/core/mail/utils.py @@ -14,6 +14,10 @@ class CachedDnsName: def get_fqdn(self): if not hasattr(self, '_fqd... | 2019-07-02T10:29:28Z | 3.0 | ["test_non_ascii_dns_non_unicode_email (mail.tests.MailTests)"] | ["test_7bit (mail.tests.PythonGlobalState)", "test_8bit_latin (mail.tests.PythonGlobalState)", "test_8bit_non_latin (mail.tests.PythonGlobalState)", "test_utf8 (mail.tests.PythonGlobalState)", "test_date_header_localtime (mail.tests.MailTimeZoneTests)", "test_date_header_utc (mail.tests.MailTimeZoneTests)", "test_close... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11603 | f618e033acd37d59b536d6e6126e6c5be18037f6 | 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
@@ -99,6 +99,7 @@ def _get_repr_options(self):
class Avg(FixDurationInputMixin, NumericOutputFieldMixin, Aggregate):
function = 'AVG'
name = 'Avg'
+ allow_... | diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -388,9 +388,6 @@ def test_count(self):
vals = Book.objects.aggregate(Count("rating"))
self.assertEqual(vals, {"rating__count": 6})
- vals = Book.objects.ag... | ## Issue Description
Django's aggregate functions `Avg` and `Sum` currently do **not support the `distinct=True` parameter**, even though the underlying SQL generation mechanism supports it. Starting from Django 2.2, using `distinct=True` with these aggregates raises a `TypeError`, because the aggregate classes do not... | PR | 2019-07-28T18:14:23Z | 3.0 | ["test_distinct_on_aggregate (aggregation.tests.AggregateTestCase)", "test_empty_aggregate (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... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11555 | 8dd5877f58f84f2b11126afbd0813e24545919ed | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -722,6 +722,9 @@ def find_ordering_name(self, name, opts, alias=None, default_order='ASC',
results = []
for item in opts.ordering:... | diff --git a/tests/ordering/models.py b/tests/ordering/models.py
--- a/tests/ordering/models.py
+++ b/tests/ordering/models.py
@@ -54,6 +54,10 @@ class Meta:
ordering = (models.F('author').asc(nulls_first=True), 'id')
+class ChildArticle(Article):
+ pass
+
+
class Reference(models.Model):
article ... | ## Issue Description
When using Django's ORM `order_by()` on a model that inherits from a parent model, and the parent's `Meta.ordering` includes a query expression (e.g., `OrderBy` objects), the framework crashes during SQL compilation. This occurs because the ordering logic expects string-based field names but recei... | Thanks for the report. I attached a regression test. Reproduced at c498f088c584ec3aff97409fdc11b39b28240de9.
Regression test.
I *think* I'm getting a similar (or same) error when adding lowercased ordering to a model via meta: class Recipe(models.Model): # ... class Meta: ordering = (Lower('name'),) This works fine in ... | 2019-07-10T18:07:07Z | 3.0 | ["test_order_by_ptr_field_with_default_ordering_by_expression (ordering.tests.OrderingTests)"] | ["test_default_ordering (ordering.tests.OrderingTests)", "F expressions can be used in Meta.ordering.", "test_default_ordering_override (ordering.tests.OrderingTests)", "test_deprecated_values_annotate (ordering.tests.OrderingTests)", "test_extra_ordering (ordering.tests.OrderingTests)", "test_extra_ordering_quoting (o... | 419a78300f7cd27611196e1e464d50fd0385ff27 | <15 min fix |
django/django | django__django-11551 | 7991111af12056ec9a856f35935d273526338c1f | diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -720,33 +720,33 @@ def _check_list_display_item(self, obj, item, label):
return []
elif hasattr(obj, item):
return []
- elif... | diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py
--- a/tests/modeladmin/test_checks.py
+++ b/tests/modeladmin/test_checks.py
@@ -3,7 +3,7 @@
from django.contrib.admin.options import VERTICAL, ModelAdmin, TabularInline
from django.contrib.admin.sites import AdminSite
from django.core.che... | ## Issue Description
Django's admin validation system improperly raises error `admin.E108` (`"The value of 'list_display[...]' refers to '...' which is not a callable..."`) for model fields that are **descriptors** defined in third-party libraries like `PositionField` from `django-positions`.
This issue was **introdu... | fix
Fix is quite simple but a regression test can be tricky.
Hi felixxm, I also just made a ticket #30545 with more details. Working through all the logical combinations I think both the old code and new code have other bugs and I've posted a suggested fix there.
Updated description with detail from #30545
I think ther... | 2019-07-09T22:28:45Z | 3.0 | ["test_valid_field_accessible_via_instance (modeladmin.test_checks.ListDisplayTests)"] | ["test_not_integer (modeladmin.test_checks.ExtraCheckTests)", "test_valid_case (modeladmin.test_checks.ExtraCheckTests)", "test_duplicate_fields_in_fields (modeladmin.test_checks.FieldsCheckTests)", "test_inline (modeladmin.test_checks.FieldsCheckTests)", "test_missing_field (modeladmin.test_checks.FkNameCheckTests)", ... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11734 | 999891bd80b3d02dd916731a7a239e1036174885 | 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
@@ -2332,10 +2332,6 @@ def get_db_prep_value(self, value, connection, prepared=False):
value = connection.ops.validate_autopk_value(valu... | diff --git a/tests/queries/tests.py b/tests/queries/tests.py
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -6,7 +6,7 @@
from django.core.exceptions import EmptyResultSet, FieldError
from django.db import DEFAULT_DB_ALIAS, connection
-from django.db.models import Count, F, Q
+from django.db.models imp... | ## Issue Description
The issue involves the improper handling of `OuterRef()` in Django ORM when used inside an `exclude()` clause or negated `Q()` objects within a subquery, specifically in the context of `Exists()` annotations. Although `OuterRef()` is designed to reference fields from the outer query within a subqu... | Thanks for the report. ValueError was fixed in 35431298226165986ad07e91f9d3aca721ff38ec. Provided test fails on master with django.db.utils.ProgrammingError: missing FROM-clause entry for table "V0" LINE 1: ...(U1."tag_id" = U2."id") WHERE U2."category_id" = ("V0"."id")... It looks that OuterRef resolves to "V0"."id" i... | 2019-09-01T18:46:50Z | 3.0 | ["test_subquery_exclude_outerref (queries.tests.ExcludeTests)"] | ["test_ticket8597 (queries.tests.ComparisonTests)", "#13227 -- If a queryset is already evaluated, it can still be used as a query arg", "test_no_fields_cloning (queries.tests.CloneTests)", "test_no_model_options_cloning (queries.tests.CloneTests)", "test_exists (queries.tests.ExistsSql)", "test_ticket_18414 (queries.t... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11728 | 05457817647368be4b019314fcc655445a5b4c0c | diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
--- a/django/contrib/admindocs/utils.py
+++ b/django/contrib/admindocs/utils.py
@@ -155,6 +155,8 @@ def replace_named_groups(pattern):
Find named groups in `pattern` and replace them with the group name. E.g.,
1. ^(?P<a>\w+)/b/... | diff --git a/tests/admin_docs/test_views.py b/tests/admin_docs/test_views.py
--- a/tests/admin_docs/test_views.py
+++ b/tests/admin_docs/test_views.py
@@ -348,9 +348,13 @@ def test_simplify_regex(self):
(r'^a', '/a'),
(r'^(?P<a>\w+)/b/(?P<c>\w+)/$', '/<a>/b/<c>/'),
(r'^(?P<a>\w+)/... | ## Issue Description
The `replace_named_groups()` function in Django fails to correctly replace the final named capturing group in regex patterns that do **not** end with a trailing slash (`/`). This is a critical bug impacting URL pattern conversion, where named groups denoted as `(?P<name>...)` should be simplified ... | Here's execution of the example code: (env) django-example$ python demo.py path: entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+) expected: entries/<pk>/relationships/<related_field> got: entries/<pk>/relationships/(?P<related_field>\w+) path_trailing: entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\... | 2019-08-29T17:31:03Z | 3.0 | ["test_simplify_regex (admin_docs.test_views.AdminDocViewFunctionsTests)", "test_app_not_found (admin_docs.test_views.TestModelDetailView)"] | ["test_builtin_fields (admin_docs.test_views.TestFieldType)", "test_custom_fields (admin_docs.test_views.TestFieldType)", "test_field_name (admin_docs.test_views.TestFieldType)", "test_descriptions_render_correctly (admin_docs.test_views.TestModelDetailView)", "Model properties are displayed as fields.", "test_method_d... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11740 | 003bb34b218adb23d1a7e67932a6ba9b3c4dcc81 | diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -912,6 +912,7 @@ def generate_altered_fields(self):
old_field_name = self.renamed_fields.get((app_label, model_name, field_name),... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -352,6 +352,11 @@ class AutodetectorTests(TestCase):
("author", models.ForeignKey("migrations.UnmigratedModel", models.CASCADE)),... | ## Issue Description
When altering a `UUIDField` to a `ForeignKey` in Django, the migration auto-detector fails to generate the appropriate **migration dependencies** for the target model. As a result, the migration may be applied **before** the target model's table is created, causing a `ValueError: Related model 'ap... | Django project which show the bug
There's a lot of history in here, so it may turn out this is a duplicate, but I'll accept this for now, as there's certainly a bug. makemigrations generats this: dependencies = [ ('testapp1', '0002_app1_another_app'), ] operations = [ migrations.AlterField( model_name='app1', name='ano... | 2019-09-03T10:44:38Z | 3.0 | ["test_alter_field_to_fk_dependency_other_app (migrations.test_autodetector.AutodetectorTests)"] | ["test_add_alter_order_with_respect_to (migrations.test_autodetector.AutodetectorTests)", "test_add_blank_textfield_and_charfield (migrations.test_autodetector.AutodetectorTests)", "Test change detection of new constraints.", "test_add_date_fields_with_auto_now_add_asking_for_default (migrations.test_autodetector.Autod... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11749 | 350123f38c2b6217c38d70bfbd924a9ba3df1289 | diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -130,11 +130,19 @@ def get_actions(parser):
yield opt
parser_actions = list(get_actions(parser))
+ mutually_exclusive_requi... | diff --git a/tests/user_commands/management/commands/mutually_exclusive_required.py b/tests/user_commands/management/commands/mutually_exclusive_required.py
new file mode 100644
--- /dev/null
+++ b/tests/user_commands/management/commands/mutually_exclusive_required.py
@@ -0,0 +1,12 @@
+from django.core.management.base ... | ## Issue Description
The `call_command` function in Django fails to correctly handle keyword arguments that belong to a required mutually exclusive group in management commands. Specifically, when a command defines a mutually exclusive group marked as `required=True`, and one of its arguments is passed as a keyword ar... | Thanks for this report. I attached a simple test. Reproduced at ed2d411aa84efc76baba3adf0d0f99df0e44ba57. | 2019-09-05T21:47:44Z | 3.0 | ["test_mutually_exclusive_group_required_options (user_commands.tests.CommandTests)"] | ["test_get_random_secret_key (user_commands.tests.UtilsTests)", "test_is_ignored_path_false (user_commands.tests.UtilsTests)", "test_is_ignored_path_true (user_commands.tests.UtilsTests)", "test_no_existent_external_program (user_commands.tests.UtilsTests)", "test_normalize_path_patterns_truncates_wildcard_base (user_c... | 419a78300f7cd27611196e1e464d50fd0385ff27 | 15 min - 1 hour |
django/django | django__django-11790 | b1d6b35e146aea83b171c1b921178bbaae2795ed | 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
@@ -191,7 +191,9 @@ def __init__(self, request=None, *args, **kwargs):
# Set the max length and label for the "username" field.
self.username_field = UserMod... | 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
@@ -423,6 +423,7 @@ def test_username_field_max_length_matches_user_model(self):
CustomEmailField.objects.create_user(**data)
form = AuthenticationForm... | # Enhanced Problem Statement: AuthenticationForm `username` Field Missing `maxlength` HTML Attribute
## Issue Description
The Django `AuthenticationForm` is missing the `maxlength` HTML attribute on its `username` field during rendering. This represents a regression that was introduced in changeset 5ceaf14686ce626404... | Regression test. | 2019-09-17T14:33:44Z | 3.1 | ["test_username_field_max_length_defaults_to_254 (auth_tests.test_forms.AuthenticationFormTest)", "test_username_field_max_length_matches_user_model (auth_tests.test_forms.AuthenticationFormTest)"] | ["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... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-11815 | e02f67ef2d03d48128e7a118bf75f0418e24e8ac | 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
@@ -120,9 +120,10 @@ class EnumSerializer(BaseSerializer):
def serialize(self):
enum_class = self.value.__class__
module = enum_cl... | 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
@@ -257,6 +257,10 @@ class TextEnum(enum.Enum):
A = 'a-value'
B = 'value-b'
+ class TextTranslatedEnum(enum.Enum):
+ A ... | ## Issue Description
When using a standard Python `Enum` with translated `.value` attributes as the `default` for a Django `CharField`, the generated migration files incorrectly serialize the **value** of the enum member (e.g., `'Good'`) rather than the **name** (e.g., `'GOOD'`). This causes migration failures if the ... | Thanks for this report, however I'm not sure how translated values can brake migrations. Can you provide a sample project to reproduce this issue? Migrations with translatable strings works fine for me: >>> class TextEnum(enum.Enum): ... C = _('translatable value') ... >>> TextEnum(_('translatable value')) <TextEnum.C:... | 2019-09-24T21:45:36Z | 3.1 | ["test_serialize_class_based_validators (migrations.test_writer.WriterTests)", "test_serialize_enums (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... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-11820 | c2678e49759e5c4c329bff0eeca2886267005d21 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1708,9 +1708,15 @@ def _check_ordering(cls):
fld = None
for part in field.split(LOOKUP_SEP):
try:
- fld = _cls._meta.get_field(... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -814,6 +814,26 @@ class Meta:
)
])
+ def test_ordering_pointing_multiple_times_to_model_fields(... | ## Issue Description
Django raises `models.E015` validation error when a model's `Meta.ordering` references the `pk` of a related model using the `__pk` syntax (e.g., `'option__pk'`). This error incorrectly flags the field reference as nonexistent, even though it is a valid and expected way to order by a related objec... | Regression test.
Thanks @felixxm for the test. I will prepare a fix for it. | 2019-09-26T08:37:14Z | 3.1 | ["test_ordering_pointing_multiple_times_to_model_fields (invalid_models_tests.test_models.OtherModelTests)", "test_ordering_pointing_to_related_model_pk (invalid_models_tests.test_models.OtherModelTests)"] | ["test_check_constraints (invalid_models_tests.test_models.ConstraintsTests)", "test_check_constraints_required_db_features (invalid_models_tests.test_models.ConstraintsTests)", "test_db_column_clash (invalid_models_tests.test_models.FieldNamesTests)", "test_ending_with_underscore (invalid_models_tests.test_models.Fiel... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-11885 | 04ac9b45a34440fa447feb6ae934687aacbfc5f4 | diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py
--- a/django/contrib/admin/utils.py
+++ b/django/contrib/admin/utils.py
@@ -182,9 +182,9 @@ def collect(self, objs, source=None, source_attr=None, **kwargs):
except models.ProtectedError as e:
self.protected.update(e.protec... | diff --git a/tests/delete/tests.py b/tests/delete/tests.py
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -582,3 +582,11 @@ def test_fast_delete_empty_no_update_can_self_select(self):
User.objects.filter(avatar__desc='missing').delete(),
(0, {'delete.User': 0})
... | ## Issue Description
When Django emulates `ON DELETE CASCADE` behavior via `models.CASCADE`, the `deletion.Collector` attempts to use a "fast path" for deletions by issuing `DELETE FROM table WHERE pk IN (...)` queries. There are conditions under which the fast path is taken, but when multiple foreign key relationship... | 2019-10-08T15:22:07Z | 3.1 | ["test_fast_delete_combined_relationships (delete.tests.FastDeleteTests)"] | ["test_fast_delete_empty_no_update_can_self_select (delete.tests.FastDeleteTests)", "test_fast_delete_fk (delete.tests.FastDeleteTests)", "test_fast_delete_inheritance (delete.tests.FastDeleteTests)", "test_fast_delete_instance_set_pk_none (delete.tests.FastDeleteTests)", "test_fast_delete_joined_qs (delete.tests.FastD... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 1-4 hours | |
django/django | django__django-11848 | f0adf3b9b7a19cdee05368ff0c0c2d087f011180 | diff --git a/django/utils/http.py b/django/utils/http.py
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -176,10 +176,14 @@ def parse_http_date(date):
try:
year = int(m.group('year'))
if year < 100:
- if year < 70:
- year += 2000
+ current_year = date... | diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -1,5 +1,6 @@
import unittest
from datetime import datetime
+from unittest import mock
from django.test import SimpleTestCase, ignore_warnings
from django.utils.... | # django.utils.http.parse_http_date Two-Digit Year Handling Bug
## Issue Description
The Django utility function `django.utils.http.parse_http_date` incorrectly handles two-digit years in RFC 850 date format according to RFC 7231 specifications. Currently, the implementation uses hard-coded year ranges (0-69 mapping ... | Accepted, however I don't think your patch is correct. The check should be relative to the current year, if I read the RFC quote correctly.
Created a pull request: Created a pull request: https://github.com/django/django/pull/9214
Still some suggested edits on the PR.
I added regression test that fails with old code (... | 2019-09-28T04:28:22Z | 3.1 | ["test_parsing_rfc850 (utils_tests.test_http.HttpDateProcessingTests)", "test_parsing_year_less_than_70 (utils_tests.test_http.HttpDateProcessingTests)"] | ["test_input_too_large (utils_tests.test_http.Base36IntTests)", "test_invalid_literal (utils_tests.test_http.Base36IntTests)", "test_negative_input (utils_tests.test_http.Base36IntTests)", "test_roundtrip (utils_tests.test_http.Base36IntTests)", "test_to_base36_errors (utils_tests.test_http.Base36IntTests)", "test_to_i... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-11951 | 312049091288dbba2299de8d07ea3e3311ed7238 | 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
@@ -1209,7 +1209,8 @@ def _batched_insert(self, objs, fields, batch_size, ignore_conflicts=False):
if ignore_conflicts and not connections[self.db].features.supports_ignore_conflic... | diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py
--- a/tests/bulk_create/tests.py
+++ b/tests/bulk_create/tests.py
@@ -1,3 +1,4 @@
+from math import ceil
from operator import attrgetter
from django.db import IntegrityError, NotSupportedError, connection
@@ -214,6 +215,14 @@ def test_explicit_bat... | ## Issue Description
In Django's `bulk_create` method, when a user explicitly provides a `batch_size` parameter, it overrides the database backend's computed maximum compatible batch size. This can result in performance degradation or database errors if the user-provided `batch_size` exceeds what the underlying databa... | 2019-10-21T09:35:46Z | 3.1 | ["test_explicit_batch_size_respects_max_batch_size (bulk_create.tests.BulkCreateTests)"] | ["test_batch_same_vals (bulk_create.tests.BulkCreateTests)", "test_bulk_insert_expressions (bulk_create.tests.BulkCreateTests)", "test_bulk_insert_nullable_fields (bulk_create.tests.BulkCreateTests)", "test_efficiency (bulk_create.tests.BulkCreateTests)", "test_empty_model (bulk_create.tests.BulkCreateTests)", "test_ex... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix | |
django/django | django__django-11964 | fc2b1cc926e34041953738e58fa6ad3053059b22 | diff --git a/django/db/models/enums.py b/django/db/models/enums.py
--- a/django/db/models/enums.py
+++ b/django/db/models/enums.py
@@ -60,7 +60,13 @@ def values(cls):
class Choices(enum.Enum, metaclass=ChoicesMeta):
"""Class for creating enumerated choices."""
- pass
+
+ def __str__(self):
+ """
+ ... | diff --git a/tests/model_enums/tests.py b/tests/model_enums/tests.py
--- a/tests/model_enums/tests.py
+++ b/tests/model_enums/tests.py
@@ -143,6 +143,12 @@ class Fruit(models.IntegerChoices):
APPLE = 1, 'Apple'
PINEAPPLE = 1, 'Pineapple'
+ def test_str(self):
+ for test in ... | # Enhanced Problem Statement: Type Mismatch in Django TextChoices/IntegerChoices Field Values
## Issue Description
When using Django's `TextChoices` or `IntegerChoices` enums with model fields, there is an inconsistent type behavior between newly created model instances and retrieved instances.
Specifically, when a... | Hi NyanKiyoshi, what a lovely report. Thank you. Clearly :) the expected behaviour is that test_created_object_is_str should pass. It's interesting that the underlying __dict__ values differ, which explains all I guess: Created: {'_state': <django.db.models.base.ModelState object at 0x10730efd0>, 'id': 1, 'my_str_value... | 2019-10-23T14:16:45Z | 3.1 | ["test_str (model_enums.tests.ChoicesTests)", "test_textchoices (model_enums.tests.ChoicesTests)"] | ["test_integerchoices (model_enums.tests.ChoicesTests)", "test_integerchoices_auto_label (model_enums.tests.ChoicesTests)", "test_integerchoices_containment (model_enums.tests.ChoicesTests)", "test_integerchoices_empty_label (model_enums.tests.ChoicesTests)", "test_integerchoices_functional_api (model_enums.tests.Choic... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-11880 | 06909fe084f87a65459a83bd69d7cdbe4fce9a7c | diff --git a/django/forms/fields.py b/django/forms/fields.py
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -199,6 +199,7 @@ def __deepcopy__(self, memo):
result = copy.copy(self)
memo[id(self)] = result
result.widget = copy.deepcopy(self.widget, memo)
+ result.error_mess... | diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -3685,6 +3685,17 @@ def test_empty_data_files_multi_value_dict(self):
self.assertIsInstance(p.data, MultiValueDict)
self... | # Enhanced Problem Statement: Django Form Field `__deepcopy__` Sharing Error Messages Between Instances
---
## Issue Description
The `__deepcopy__` method implemented in Django form fields (defined in `django/forms/fields.py`) fails to perform a true deep copy of the `error_messages` attribute. Instead, it uses shal... | Thanks for this report. I attached a simple test. Reproduced at f52022ad96356d4b1061610f2b74ea4d1956a608.
Simple test.
PR | 2019-10-07T19:10:59Z | 3.1 | ["test_field_deep_copy_error_messages (forms_tests.tests.test_forms.FormsTestCase)"] | ["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-11999 | 84633905273fc916e3d17883810d9969c03f73c2 | 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
@@ -763,8 +763,12 @@ def contribute_to_class(self, cls, name, private_only=False):
if not getattr(cls, self.attname, None):
... | 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
@@ -168,6 +168,16 @@ def test_get_FIELD_display_translated(self):
self.assertIsInstance(val, str)
self.assertEqual(val, 'translated')
+ def test_overriding_FI... | ## Issue Description
Since Django 2.2, overriding the automatically generated `get_FOO_display()` method on model instances no longer works as expected. In earlier versions (e.g., Django 2.1), custom implementations of these methods were properly called and returned the expected values. However, in Django 2.2+, the fr... | Thanks for this report. Regression in a68ea231012434b522ce45c513d84add516afa60. Reproduced at 54a7b021125d23a248e70ba17bf8b10bc8619234.
OK, I have a lead on this. Not at all happy about how it looks at first pass, but I'll a proof of concept PR together for it tomorrow AM.
I don't think it should be marked as blocker s... | 2019-10-31T10:39:18Z | 3.1 | ["test_overriding_FIELD_display (model_fields.tests.GetFieldDisplayTests)"] | ["test_blank_in_choices (model_fields.tests.GetChoicesTests)", "test_blank_in_grouped_choices (model_fields.tests.GetChoicesTests)", "test_empty_choices (model_fields.tests.GetChoicesTests)", "test_lazy_strings_not_evaluated (model_fields.tests.GetChoicesTests)", "test_check (model_fields.tests.ChoicesTests)", "test_ch... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12039 | 58c1acb1d6054dfec29d0f30b1033bae6ef62aec | diff --git a/django/db/backends/ddl_references.py b/django/db/backends/ddl_references.py
--- a/django/db/backends/ddl_references.py
+++ b/django/db/backends/ddl_references.py
@@ -83,10 +83,14 @@ def __init__(self, table, columns, quote_name, col_suffixes=()):
def __str__(self):
def col_str(column, idx):... | diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -75,6 +75,22 @@ def test_index_together_single_list(self):
index_sql = connection.schema_editor()._model_indexes_sql(IndexTogetherSingleList)
self.assertEqual(len(index_sql), 1)
... | ## Issue Description
When creating database indexes using Django's `Index` class, the generated `CREATE INDEX` SQL statements include improper whitespace around column definitions, particularly when using PostgreSQL with opclasses.
The root cause is in how ordering suffixes (like `DESC`) and opclass specifications (l... | PR: https://github.com/django/django/pull/12039
OK, I'll Accept this as a clean up (there's not actually an error right?). The patch looks small/clean enough at first glance.
Correct, no error. But since it's not documented as valid syntax to not have whitespace between the column and the ordering it could break in fu... | 2019-11-06T21:14:34Z | 3.1 | ["test_descending_columns_list_sql (indexes.tests.SchemaIndexesTests)"] | ["test_columns_list_sql (indexes.tests.SchemaIndexesTests)", "test_index_name (indexes.tests.SchemaIndexesTests)", "test_index_name_hash (indexes.tests.SchemaIndexesTests)", "test_index_together (indexes.tests.SchemaIndexesTests)", "test_index_together_single_list (indexes.tests.SchemaIndexesTests)", "test_create_index... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12125 | 89d41cba392b759732ba9f1db4ff29ed47da6a56 | 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
@@ -269,7 +269,7 @@ def serialize(self):
if module == builtins.__name__:
return self.value.__name__, set()
els... | 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
@@ -26,6 +26,11 @@
from .models import FoodManager, FoodQuerySet
+class DeconstructibleInstances:
+ def deconstruct(self):
+ return ('DeconstructibleI... | # Django makemigrations generates incorrect import paths for inner classes
## Issue Description
When a Django model uses a field defined as an inner class (e.g., `Outer.Inner`), the `makemigrations` command generates migration files with incorrect import paths. Instead of using the fully qualified name including the ... | This should be possible to do by relying on __qualname__ (instead of __name__) now that master is Python 3 only.
PR
I think we should focus on using __qualname__ during migration serialization as well instead of simply solving the field subclasses case.
In fb0f987: Fixed #27914 -- Added support for nested classes in F... | 2019-11-22T12:55:45Z | 3.1 | ["test_serialize_nested_class (migrations.test_writer.WriterTests)", "test_serialize_numbers (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... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12050 | b93a0e34d9b9b99d41103782b7e7aeabf47517e3 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1059,21 +1059,10 @@ def resolve_lookup_value(self, value, can_reuse, allow_joins, simple_col):
elif isinstance(value, (list, tuple)):
# The items o... | diff --git a/tests/queries/test_query.py b/tests/queries/test_query.py
--- a/tests/queries/test_query.py
+++ b/tests/queries/test_query.py
@@ -113,3 +113,10 @@ def test_clone_select_related(self):
clone = query.clone()
clone.add_select_related(['note', 'creator__extra'])
self.assertEqual(quer... | ## Issue Description
In Django's ORM query system, the `Query.resolve_lookup_value` method coerces input values of type `list` into `tuple`. This behavior was introduced in [ticket #30687](https://code.djangoproject.com/ticket/30687) as part of a change to normalize iterable lookups for database queries. However, thi... | 2019-11-10T08:53:45Z | 3.1 | ["test_iterable_lookup_value (queries.test_query.TestQuery)"] | ["test_clone_select_related (queries.test_query.TestQuery)", "test_complex_query (queries.test_query.TestQuery)", "test_foreign_key (queries.test_query.TestQuery)", "test_foreign_key_exclusive (queries.test_query.TestQuery)", "test_foreign_key_f (queries.test_query.TestQuery)", "test_multiple_fields (queries.test_query... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12143 | 5573a54d409bb98b5c5acdb308310bed02d392c2 | 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
@@ -1631,7 +1631,9 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
def _get_edited_object_pks(self, request, prefix):
... | diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -844,6 +844,26 @@ def test_get_list_editable_queryset(self):
queryset = m._get_list_editable_queryset(request, prefix='form')
self.assertEqual(q... | ## Issue Description
A potential data loss vulnerability exists in Django's admin changeform view when a formset's prefix contains regular expression special characters. This occurs due to unsafe string formatting used to construct a regex pattern in `django/contrib/admin/options.py`. Specifically, the line in questio... | 2019-11-25T14:38:30Z | 3.1 | ["test_get_list_editable_queryset_with_regex_chars_in_prefix (admin_changelist.tests.ChangeListTests)"] | ["test_custom_user_pk_not_named_id (admin_changelist.tests.GetAdminLogTests)", "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.GetAdminLogTe... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12155 | e8fcdaad5c428878d0a5d6ba820d957013f75595 | diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
--- a/django/contrib/admindocs/utils.py
+++ b/django/contrib/admindocs/utils.py
@@ -3,6 +3,7 @@
import re
from email.errors import HeaderParseError
from email.parser import HeaderParser
+from inspect import cleandoc
from django.url... | diff --git a/tests/admin_docs/test_utils.py b/tests/admin_docs/test_utils.py
--- a/tests/admin_docs/test_utils.py
+++ b/tests/admin_docs/test_utils.py
@@ -1,8 +1,9 @@
import unittest
from django.contrib.admindocs.utils import (
- docutils_is_available, parse_docstring, parse_rst, trim_docstring,
+ docutils_is... | ## Issue Description
In Django's `admindoc` module, the `trim_docstring` function in `django/contrib/admindocs/utils.py` incorrectly calculates the minimum indentation of a docstring when the first line of the docstring contains content (i.e., is not empty). This leads to incorrect trimming of leading whitespace from ... | Confirmed the patch fixes the issue, although it crashes for some tests with ValueError: min() arg is an empty sequence.
We should probably just switch to inspect.cleandoc as it implements the algorithm defined in PEP257.
Replying to Tim Graham: Confirmed the patch fixes the issue, although it crashes for some tests ... | 2019-11-28T16:24:23Z | 3.1 | ["test_parse_rst_with_docstring_no_leading_line_feed (admin_docs.test_utils.TestUtils)"] | ["test_description_output (admin_docs.test_utils.TestUtils)", "test_initial_header_level (admin_docs.test_utils.TestUtils)", "test_parse_docstring (admin_docs.test_utils.TestUtils)", "test_parse_rst (admin_docs.test_utils.TestUtils)", "test_publish_parts (admin_docs.test_utils.TestUtils)", "test_title_output (admin_doc... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12209 | 5a68f024987e6d16c2626a31bf653a2edddea579 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -849,6 +849,7 @@ def _save_table(self, raw=False, cls=None, force_insert=False,
updated = False
# Skip an UPDATE when adding an instance and primary key has a default.
... | diff --git a/tests/serializers/models/data.py b/tests/serializers/models/data.py
--- a/tests/serializers/models/data.py
+++ b/tests/serializers/models/data.py
@@ -4,6 +4,8 @@
NULL values, where allowed.
The basic idea is to have a model for each Django data type.
"""
+import uuid
+
from django.contrib.contenttypes.... | ## Issue Description
In Django 3.0, there's a backward-incompatible change in how saving model instances with an explicitly set primary key (pk) behaves when the pk field also defines a `default` value (e.g., `UUIDField` with `default=uuid4`). Specifically, a model instance that would previously have resulted in one `... | It looks like the logic in _save_table should not force an insert if an explicit pk value is provided. The logic should likely take pk_set into account if ( not pk_set and self._state.adding and self._meta.pk.default and self._meta.pk.default is not NOT_PROVIDED ): force_insert = True I'm surprised this was not caught... | 2019-12-12T04:11:05Z | 3.1 | ["partial(func, *args, **keywords) - new function with partial application"] | [] | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12193 | 3fb7c12158a2402f0f80824f6778112071235803 | diff --git a/django/forms/widgets.py b/django/forms/widgets.py
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -522,9 +522,7 @@ def format_value(self, value):
def get_context(self, name, value, attrs):
if self.check_test(value):
- if attrs is None:
- attrs = {}
-... | diff --git a/tests/forms_tests/widget_tests/test_checkboxinput.py b/tests/forms_tests/widget_tests/test_checkboxinput.py
--- a/tests/forms_tests/widget_tests/test_checkboxinput.py
+++ b/tests/forms_tests/widget_tests/test_checkboxinput.py
@@ -89,3 +89,8 @@ def test_value_from_datadict_string_int(self):
def test_va... | ## Issue Description
In Django, when using a `SplitArrayField` with `BooleanField` widgets and providing preexisting array data (e.g., `[False, True, False]`), all checkboxes rendered after the first `True` value incorrectly appear as checked — even if their corresponding data value is `False`.
This behavior occurs d... | Changes available here: https://github.com/django/django/pull/12193
Thanks for the report. Reproduced at 5708327c3769262b845730996ca2784245ada4d1. | 2019-12-08T01:38:25Z | 3.1 | ["test_get_context_does_not_mutate_attrs (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)"] | ["test_render_check_exception (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)", "test_render_check_test (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)", "test_render_empty (forms_tests.widget_tests.test_checkboxinput.CheckboxInputTest)", "test_render_false (forms_tests.widget_tests.test... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12276 | 53d8646f799de7f92ab9defe9dc56c6125448102 | diff --git a/django/forms/widgets.py b/django/forms/widgets.py
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -387,6 +387,9 @@ def value_from_datadict(self, data, files, name):
def value_omitted_from_data(self, data, files, name):
return name not in files
+ def use_required_attribute(... | 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
@@ -8,11 +8,11 @@
from django.core.validators import MaxValueValidator, RegexValidator
from django.forms import (
BooleanField, CharFi... | # Enhanced Problem Statement: FileInput Should Not Display Required Attribute When Initial Data Exists
## Issue Description
The Django `FileInput` widget incorrectly renders the HTML `required` attribute even when a file is already associated with the form field (e.g., when editing an existing model instance that alr... | This might explain better: from django import forms from django.core.files.base import ContentFile from django.test import SimpleTestCase class FileForm(forms.Form): file = forms.FileField(widget=forms.FileInput) class FileInputRenderTest(SimpleTestCase): def test_file_input(self): form = FileForm() field = form['file'... | 2020-01-05T08:04:40Z | 3.1 | ["test_use_required_attribute (forms_tests.widget_tests.test_fileinput.FileInputTest)", "test_filefield_with_fileinput_required (forms_tests.tests.test_forms.FormsTestCase)"] | ["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12262 | 69331bb851c34f05bc77e9fc24020fe6908b9cd5 | diff --git a/django/template/library.py b/django/template/library.py
--- a/django/template/library.py
+++ b/django/template/library.py
@@ -261,7 +261,7 @@ def parse_bits(parser, bits, params, varargs, varkw, defaults,
if kwarg:
# The kwarg was successfully extracted
param, value = kwa... | diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py
--- a/tests/template_tests/templatetags/inclusion.py
+++ b/tests/template_tests/templatetags/inclusion.py
@@ -136,6 +136,15 @@ def inclusion_one_default(one, two='hi'):
inclusion_one_default.anything = "Expecte... | ## Issue Description
Django's custom template tags (created using `@register.simple_tag` or `@register.inclusion_tag`) raise incorrect or misleading `TemplateSyntaxError` exceptions when **keyword-only arguments with defaults** are used. The core issue arises during argument parsing and validation in Django’s template... | 2019-12-30T13:13:59Z | 3.1 | ["test_inclusion_tag_errors (template_tests.test_custom.InclusionTagTests)", "test_inclusion_tags (template_tests.test_custom.InclusionTagTests)", "test_simple_tag_errors (template_tests.test_custom.SimpleTagTests)", "test_simple_tags (template_tests.test_custom.SimpleTagTests)"] | ["test_decorated_filter (template_tests.test_custom.CustomFilterTests)", "test_filter (template_tests.test_custom.CustomFilterTests)", "test_15070_use_l10n (template_tests.test_custom.InclusionTagTests)", "test_include_tag_missing_context (template_tests.test_custom.InclusionTagTests)", "test_inclusion_tag_registration... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12273 | 927c903f3cd25c817c21738328b53991c035b415 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -569,6 +569,9 @@ def _get_pk_val(self, meta=None):
return getattr(self, meta.pk.attname)
def _set_pk_val(self, value):
+ for parent_link in self._meta.parents.values()... | diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -10,10 +10,11 @@
from .models import (
ArticleWithAuthor, BachelorParty, BirthdayParty, BusStation, Child,
- Derive... | # Enhanced Problem Statement: Primary Key Reset Not Working in Django Child Model
## Issue Description
When attempting to reset the primary key of a Django model instance by setting it to `None` and then calling `save()`, the operation fails to create a new record for child models using model inheritance. Instead of ... | I'm not sure if this is a bug. The test passes after adding self.item_ptr = None to Item.reset(). Is that the behavior you're looking for?
I agree with Tim here. It feels like what you're after is self.pk = None as it will be alias for self.item_ptr for Derived instances and self.uid for Item instances.
@Simon Charette... | 2020-01-03T18:47:56Z | 3.1 | ["test_create_new_instance_with_pk_equals_none (model_inheritance_regress.tests.ModelInheritanceTest)", "test_create_new_instance_with_pk_equals_none_multi_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)"] | ["test_abstract_base_class_m2m_relation_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_abstract_verbose_name_plural_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_all_fields_from_abstract_base_class (model_inheritance_regress.tests.ModelInheritanceTest)", "test_co... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12308 | 2e0f04507b17362239ba49830d26fec504d46978 | diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py
--- a/django/contrib/admin/utils.py
+++ b/django/contrib/admin/utils.py
@@ -398,6 +398,11 @@ def display_for_field(value, field, empty_value_display):
return formats.number_format(value)
elif isinstance(field, models.FileField) and... | diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py
--- a/tests/admin_utils/tests.py
+++ b/tests/admin_utils/tests.py
@@ -176,6 +176,23 @@ def test_null_display_for_field(self):
display_value = display_for_field(None, models.FloatField(), self.empty_value)
self.assertEqual(display_val... | ## Issue Description
In Django's admin interface, when `JSONField` fields are set to read-only, their values are displayed as Python dictionary literals rather than valid JSON strings. For example, a value of `{"foo": "bar"}` is displayed as `{'foo': 'bar'}`, which is not valid JSON syntax. This issue stems from the l... | PR
The proposed patch is problematic as the first version coupled contrib.postgres with .admin and the current one is based off the type name which is brittle and doesn't account for inheritance. It might be worth waiting for #12990 to land before proceeding here as the patch will be able to simply rely of django.db.m... | 2020-01-12T04:21:15Z | 3.1 | ["test_json_display_for_field (admin_utils.tests.UtilsTests)", "test_label_for_field (admin_utils.tests.UtilsTests)"] | ["test_cyclic (admin_utils.tests.NestedObjectsTests)", "test_non_added_parent (admin_utils.tests.NestedObjectsTests)", "test_on_delete_do_nothing (admin_utils.tests.NestedObjectsTests)", "test_queries (admin_utils.tests.NestedObjectsTests)", "test_relation_on_abstract (admin_utils.tests.NestedObjectsTests)", "test_sibl... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12325 | 29c126bb349526b5f1cd78facbe9f25906f18563 | 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
@@ -202,7 +202,7 @@ def __new__(cls, name, bases, attrs, **kwargs):
continue
# Locate OneToOneField instances.
for field in base._meta.local_fields:
-... | 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
@@ -3,7 +3,6 @@
from django.conf import settings
from django.core.checks import Error, Warning
from django.core.checks.mod... | ## Issue Description
In Django models using **Multi-Table Inheritance (MTI)**, the presence of multiple `OneToOneField` references to the same parent model can cause Django to incorrectly interpret which field is intended as the `parent_link`. This results in a misleading `ImproperlyConfigured` error, even when the co... | That seems to be a bug, managed to reproduce. Does the error go away if you add primary_key=True to document_ptr like I assume you wanted to do? This makes me realized that the MTI documentation is not completely correcy, the automatically added `place_ptr` field end up with `primary_key=True`. Not sure why we're not... | 2020-01-15T14:02:25Z | 3.1 | ["test_clash_parent_link (invalid_models_tests.test_relative_fields.ComplexClashTests)", "test_onetoone_with_parent_model (invalid_models_tests.test_models.OtherModelTests)"] | ["test_check_constraints (invalid_models_tests.test_models.ConstraintsTests)", "test_check_constraints_required_db_features (invalid_models_tests.test_models.ConstraintsTests)", "test_accessor_clash (invalid_models_tests.test_relative_fields.SelfReferentialFKClashTests)", "test_clash_under_explicit_related_name (invali... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 1-4 hours |
django/django | django__django-12304 | 4c1b401e8250f9f520b3c7dc369554477ce8b15a | diff --git a/django/db/models/enums.py b/django/db/models/enums.py
--- a/django/db/models/enums.py
+++ b/django/db/models/enums.py
@@ -31,6 +31,7 @@ def __new__(metacls, classname, bases, classdict):
# that is passed in as "self" as the value to use when looking up the
# label in the choices.
... | diff --git a/tests/model_enums/tests.py b/tests/model_enums/tests.py
--- a/tests/model_enums/tests.py
+++ b/tests/model_enums/tests.py
@@ -4,6 +4,7 @@
import uuid
from django.db import models
+from django.template import Context, Template
from django.test import SimpleTestCase
from django.utils.functional import ... | ## Issue Description
Enumeration types in Django, introduced for better modeling of fixed sets of values (e.g., `models.TextChoices`, `models.IntegerChoices`), are not usable directly within Django templates. This is due to the fact that these enumeration classes are **callable** — Django's templating engine attempts ... | 2020-01-09T15:43:51Z | 3.1 | ["test_templates (model_enums.tests.ChoicesTests)"] | ["test_integerchoices (model_enums.tests.ChoicesTests)", "test_integerchoices_auto_label (model_enums.tests.ChoicesTests)", "test_integerchoices_containment (model_enums.tests.ChoicesTests)", "test_integerchoices_empty_label (model_enums.tests.ChoicesTests)", "test_integerchoices_functional_api (model_enums.tests.Choic... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix | |
django/django | django__django-12406 | 335c9c94acf263901fb023404408880245b0c4b4 | diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -980,6 +980,7 @@ def formfield(self, *, using=None, **kwargs):
'queryset': self.remote_field.model._default_manager.using(using),
... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -393,6 +393,9 @@ class Character(models.Model):
username = models.CharField(max_length=100)
last_action = models.DateTimeField()
+ def __str__(self):
+ retu... | # Enhanced Problem Statement
## Issue Description
When using `RadioSelect` as a widget for a foreign key field in a Django `ModelForm`, an unwanted blank option (`---------`) is rendered even when `blank=False` is set on the model field. Unlike standard `<select>` widgets where a blank option is idiomatic for required... | A pull request is available here: https://github.com/django/django/pull/11199
PR | 2020-02-02T16:34:05Z | 3.1 | ["test_non_blank_foreign_key_with_radio (model_forms.tests.ModelFormBaseTest)", "test_choices_radio_blank (model_forms.test_modelchoicefield.ModelChoiceFieldTests)", "test_clean_model_instance (model_forms.test_modelchoicefield.ModelChoiceFieldTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "test_notrequired_overrides_notblank (model_forms.tests.ValidationTest)", "test_validates_with_replaced_field_excluded (model_forms.tests.ValidationTest)", "test_validates_with_replaced_field_not_specified (model_forms.tests.ValidationTest... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12419 | 7fa1a93c6c8109010a6ff3f604fda83b604e0e97 | diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -637,6 +637,6 @@ def gettext_noop(s):
SECURE_HSTS_PRELOAD = False
SECURE_HSTS_SECONDS = 0
SECURE_REDIRECT_EXEMPT = []
-SECURE_REFERRER_POLICY = None
+SECURE_REFERR... | diff --git a/tests/project_template/test_settings.py b/tests/project_template/test_settings.py
--- a/tests/project_template/test_settings.py
+++ b/tests/project_template/test_settings.py
@@ -38,6 +38,7 @@ def test_middleware_headers(self):
self.assertEqual(headers, [
b'Content-Length: 0',
... | # Enhanced Problem Statement: Add Secure Default for SECURE_REFERRER_POLICY / Referrer-Policy Header
## Issue Description
Django currently allows configuration of the `SECURE_REFERRER_POLICY` setting to control the HTTP `Referrer-Policy` header (added in Django 3.0 via #29406), but does not set a secure default value... | Hi Adam, Yes, I think this fits our secure by default philosophy. As long as the BC is documented in the release notes I think we should have this. | 2020-02-05T10:02:56Z | 3.1 | ["test_middleware_headers (project_template.test_settings.TestStartProjectSettings)"] | [] | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix |
django/django | django__django-12663 | fa5e7e46d875d4143510944f19d79df7b1739bab | 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
@@ -233,7 +233,8 @@ def __init__(self, model, where=WhereNode, alias_cols=True):
@property
def output_field(self):
if len(self.select) == 1:
- ... | diff --git a/tests/expressions/models.py b/tests/expressions/models.py
--- a/tests/expressions/models.py
+++ b/tests/expressions/models.py
@@ -6,10 +6,15 @@
from django.db import models
+class Manager(models.Model):
+ name = models.CharField(max_length=50)
+
+
class Employee(models.Model):
firstname = mod... | ## Issue Description
A regression has occurred in Django that breaks the usage of `SimpleLazyObject` within nested subquery annotations. Prior to a specific commit, it was possible to filter querysets using `SimpleLazyObject` instances as lookup values when working with subqueries involving `Subquery` and `OuterRef`.
... | I agree that this behavior was changed in 35431298226165986ad07e91f9d3aca721ff38ec, but you can easily create a test with SimpleLazyObject() (which is not a public API) and Subquery() that always fails with TypeError, e.g. def test_subquery_filter_by_lazy(self): test_user = SimpleLazyObject(lambda: get_user_model().obj... | 2020-04-04T18:58:49Z | 3.1 | ["test_subquery_filter_by_lazy (expressions.tests.BasicExpressionsTests)"] | ["test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTests)", "test_or (expressions.tests.CombinableTests)", "test_reversed_and (expressions.tests.CombinableTests)", "test_reversed_or (expressions.tests.CombinableTests)", "test_deconstruct (expressions.tests.FTests)", "test_deepc... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour |
django/django | django__django-12713 | 5b884d45ac5b76234eca614d90c83b347294c332 | 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
@@ -249,17 +249,25 @@ def formfield_for_manytomany(self, db_field, request, **kwargs):
return None
db = kwargs.get('using')
- autocomp... | 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
@@ -14,7 +14,9 @@
from django.contrib.auth.models import User
from django.core.files.storage import default_storage
from django.core.files.uploadedfile import SimpleUploadedF... | # Issue: Allow Overriding Widget in `formfield_for_manytomany()`
## Issue Description
In Django, the `formfield_for_manytomany()` method does **not respect** the `widget` parameter passed to it, unlike `formfield_for_foreignkey()`, which properly overrides the widget. This inconsistency makes it difficult for develop... | 2020-04-13T23:57:12Z | 3.1 | ["test_formfield_overrides_m2m_filter_widget (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... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-12754 | 18759b2209ff556aed7f20d83cbf23e3d234e41c | diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -563,6 +563,16 @@ def generate_created_models(self):
if isinstance(base, str) and "." in base:
base_app_... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -2454,3 +2454,28 @@ def test_mti_inheritance_model_removal(self):
self.assertNumberMigrations(changes, 'app', 1)
self.as... | # Enhanced Problem Statement
## Issue Description
When refactoring a Django model by creating a subclass and moving an existing field to that subclass in a single migration step, Django's migration system fails during the `migrate` command with a `FieldError`. This occurs because the migration operations are generate... | Tentatively accepted for a future investigation. I'm not sure if this is feasible because detecting changes related with models' bases are tricky. Moreover you will lose data with such change, so IMO it's preferable to handle this manually.
Maybe the makemigrations could present some kind of info about the data being l... | 2020-04-19T10:59:30Z | 3.2 | ["test_add_model_with_field_removed_from_base_model (migrations.test_autodetector.AutodetectorTests)"] | ["test_add_alter_order_with_respect_to (migrations.test_autodetector.AutodetectorTests)", "test_add_blank_textfield_and_charfield (migrations.test_autodetector.AutodetectorTests)", "Test change detection of new constraints.", "test_add_date_fields_with_auto_now_add_asking_for_default (migrations.test_autodetector.Autod... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
django/django | django__django-12741 | 537d422942b53bc0a2b6a51968f379c0de07793c | diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -60,7 +60,7 @@ def handle(self, **options):
if confirm == 'yes':
try:
- connection.ops.... | diff --git a/tests/backends/base/test_operations.py b/tests/backends/base/test_operations.py
--- a/tests/backends/base/test_operations.py
+++ b/tests/backends/base/test_operations.py
@@ -172,7 +172,7 @@ def test_execute_sql_flush_statements(self):
reset_sequences=True,
allow_cascade=True,
... | ## Issue Description
The method `DatabaseOperations.execute_sql_flush()` currently has an unnecessarily verbose signature that includes a `using` parameter which can be inferred directly from the instance (`self.connection.alias`). This redundancy leads to unnecessary verbosity in internal usage where callers are manu... | 2020-04-17T22:35:55Z | 3.1 | ["test_execute_sql_flush_statements (backends.base.test_operations.SqlFlushTests)", "test_sequence_name_length_limits_flush (backends.tests.LongNameTest)"] | ["test_parameter_escaping (backends.tests.EscapingChecksDebug)", "test_paramless_no_escaping (backends.tests.EscapingChecksDebug)", "test_django_date_extract (backends.tests.DateQuotingTest)", "test_django_date_trunc (backends.tests.DateQuotingTest)", "test_parameter_escaping (backends.tests.EscapingChecks)", "test_par... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | <15 min fix | |
django/django | django__django-12708 | 447980e72ac01da1594dd3373a03ba40b7ee6f80 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -393,7 +393,12 @@ def alter_index_together(self, model, old_index_together, new_index_together):
news = {tuple(fields) for fields in new_index_to... | diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -62,7 +62,11 @@ def assertIndexExists(self, table, columns, value=True, using='default', index_t
any(
c["index"]
... | ## Issue Description
When a Django model contains the same field combination in both `unique_together` and `index_together`, attempting to remove the `index_together` constraint during a migration leads to a `ValueError` crash. The error occurs during Django's attempt to delete an index constraint, but due to the exis... | Reproduced on master at 623139b5d1bd006eac78b375bcaf5948e695c3c6.
I haven't looked under the hood on this yet, but could it be related to the ordering of the operations generated for the mgiration? on first inspection it feels like this and #28862 could be caused by the same/similar underlying problem in how FieldRelat... | 2020-04-12T22:20:59Z | 3.1 | ["test_alter_index_together_remove_with_unique_together (migrations.test_operations.OperationTests)"] | ["test_references_model_mixin (migrations.test_operations.TestCreateModel)", "test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.Fiel... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 1-4 hours |
django/django | django__django-12774 | 67f9d076cfc1858b94f9ed6d1a5ce2327dcc8d0d | 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
@@ -689,7 +689,17 @@ def in_bulk(self, id_list=None, *, field_name='pk'):
"""
assert not self.query.is_sliced, \
"Cannot use 'limit' or 'offset' with in_bulk"... | diff --git a/tests/lookup/models.py b/tests/lookup/models.py
--- a/tests/lookup/models.py
+++ b/tests/lookup/models.py
@@ -67,6 +67,11 @@ class Season(models.Model):
gt = models.IntegerField(null=True, blank=True)
nulled_text_field = NulledTextField(null=True)
+ class Meta:
+ constraints = [
+ ... | ## Issue Description
The `QuerySet.in_bulk()` method in Django currently fails when used with fields that are made unique through `UniqueConstraint` in the model's `Meta.constraints`, rather than by setting `unique=True` on the field itself.
This discrepancy arises because Django's internal validation for `in_bulk()`... | 2020-04-22T11:02:30Z | 3.1 | ["test_in_bulk_meta_constraint (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 | 15 min - 1 hour | |
django/django | django__django-12965 | 437196da9a386bd4cc62b0ce3f2de4aba468613d | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1407,6 +1407,8 @@ def execute_sql(self, returning_fields=None):
class SQLDeleteCompiler(SQLCompiler):
@cached_property
def single_alias(self):
+ ... | diff --git a/tests/delete/tests.py b/tests/delete/tests.py
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -605,6 +605,12 @@ def receiver(instance, **kwargs):
class FastDeleteTests(TestCase):
+ def test_fast_delete_all(self):
+ with self.assertNumQueries(1) as ctx:
+ User.objects.al... | ## Issue Description
In Django 3.1, the behavior of `Model.objects.all().delete()` changed unexpectedly from prior versions, leading to a significant **performance regression** and **functional compatibility issues**, particularly when used in combination with MySQL's `LOCK TABLES`.
In Django 3.0 (and earlier), the f... | It looks like this was added in #23576 / PR #11931
It should be possible to prevent the query when dealing with a single alias. It looks like this is a regression on other backends as well. | 2020-05-24T13:20:03Z | 3.2 | ["test_fast_delete_all (delete.tests.FastDeleteTests)"] | ["test_fast_delete_combined_relationships (delete.tests.FastDeleteTests)", "test_fast_delete_empty_no_update_can_self_select (delete.tests.FastDeleteTests)", "test_fast_delete_fk (delete.tests.FastDeleteTests)", "test_fast_delete_inheritance (delete.tests.FastDeleteTests)", "test_fast_delete_instance_set_pk_none (delet... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
django/django | django__django-12858 | f2051eb8a7febdaaa43bd33bf5a6108c5f428e59 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1747,7 +1747,9 @@ def _check_ordering(cls):
else:
_cls = None
except (FieldDoesNotExist, AttributeError):
- ... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -893,6 +893,15 @@ class Meta:
with register_lookup(models.CharField, Lower):
self.assertEqual(Model.... | ## Issue Description
Django is incorrectly raising a `models.E015` system check error for model `ordering` options when they contain valid lookups like `__isnull`. Although such ordering expressions work correctly in runtime ORM queries, the system check incorrectly treats `supply__product__parent__isnull` as a non-ex... | 2020-05-05T04:49:02Z | 3.1 | ["test_ordering_pointing_to_lookup_not_transform (invalid_models_tests.test_models.OtherModelTests)"] | ["test_check_constraints (invalid_models_tests.test_models.ConstraintsTests)", "test_check_constraints_required_db_features (invalid_models_tests.test_models.ConstraintsTests)", "test_deferrable_unique_constraint (invalid_models_tests.test_models.ConstraintsTests)", "test_deferrable_unique_constraint_required_db_featur... | 0668164b4ac93a5be79f5b87fae83c657124d9ab | 15 min - 1 hour | |
django/django | django__django-13028 | 78ad4b4b0201003792bfdbf1a7781cbc9ee03539 | 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
@@ -1124,7 +1124,10 @@ def check_related_objects(self, field, value, opts):
def check_filterable(self, expression):
"""Raise an error if expression cannot be... | diff --git a/tests/queries/models.py b/tests/queries/models.py
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -68,6 +68,7 @@ class ExtraInfo(models.Model):
note = models.ForeignKey(Note, models.CASCADE, null=True)
value = models.IntegerField(null=True)
date = models.ForeignKey(DateTimePK,... | ## Issue Description
A `NotSupportedError` is raised when filtering a `QuerySet` using a related model instance which has a field named `filterable=False`. Specifically, when a model (e.g., `ProductMetaDataType`) defines a Boolean field with the exact name `filterable`, Django ORM incorrectly interprets this field as ... | Thanks for the report, that's a nice edge case. We should be able to fix this by checking if rhs is an expression: diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ce18098fd2..ad981377a0 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1124,7 +1124,7 @@ ... | 2020-06-05T19:49:04Z | 3.2 | ["test_field_with_filterable (queries.tests.Queries1Tests)", "test_ticket8439 (queries.tests.Queries1Tests)"] | ["#13227 -- If a queryset is already evaluated, it can still be used as a query arg", "test_no_fields_cloning (queries.tests.CloneTests)", "test_no_model_options_cloning (queries.tests.CloneTests)", "test_no_extra_params (queries.tests.DefaultValuesInsertTest)", "test_ticket_7302 (queries.tests.EscapingTests)", "test_t... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
django/django | django__django-13023 | f83b44075dafa429d59e8755aa47e15577cc49f9 | diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -1501,7 +1501,7 @@ def to_python(self, value):
return self.context.create_decimal_from_float(value)
try:
return... | diff --git a/tests/model_fields/test_decimalfield.py b/tests/model_fields/test_decimalfield.py
--- a/tests/model_fields/test_decimalfield.py
+++ b/tests/model_fields/test_decimalfield.py
@@ -21,9 +21,24 @@ def test_to_python(self):
# Uses default rounding of ROUND_HALF_EVEN.
self.assertEqual(f.to_pyth... | ## Issue Description
In Django's `DecimalField`, the `to_python()` method raises a `TypeError` when passed a dictionary as input instead of raising a more appropriate `ValidationError`. This behavior is inconsistent with how other Django fields handle invalid input types, where invalid values should raise `ValidationE... | 2020-06-04T20:40:44Z | 3.2 | ["test_invalid_value (model_fields.test_decimalfield.DecimalFieldTests)", "test_lookup_really_big_value (model_fields.test_decimalfield.DecimalFieldTests)"] | ["test_default (model_fields.test_decimalfield.DecimalFieldTests)", "test_filter_with_strings (model_fields.test_decimalfield.DecimalFieldTests)", "test_get_prep_value (model_fields.test_decimalfield.DecimalFieldTests)", "test_max_decimal_places_validation (model_fields.test_decimalfield.DecimalFieldTests)", "test_max_... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix | |
django/django | django__django-13033 | 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... | # Enhanced Problem Statement: Incorrect SQL Generation for Self-Referencing Foreign Key Ordering
## Issue Description
When ordering querysets by a relation's foreign key ID field (`record__root_id`) where the foreign key is self-referencing, Django generates incorrect SQL that includes:
1. **Unexpected DESC sort orde... | 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 | 15 min - 1 hour |
django/django | django__django-13012 | 22a59c01c00cf9fbefaee0e8e67fab82bbaf1fd2 | 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
@@ -863,6 +863,9 @@ def set_source_expressions(self, exprs):
def get_source_expressions(self):
return [self.expression]
+ def get_group_by_cols(se... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -1828,3 +1828,13 @@ def test_reversed_and(self):
def test_reversed_or(self):
with self.assertRaisesMessage(NotImplementedError, self.bitwise_msg):
object()... | # Enhanced Problem Statement
## Issue Description
When using Django's `ExpressionWrapper` to annotate constant expressions (like `Value(3)`) in queries that involve aggregation, the ORM incorrectly includes the constant expression in the `GROUP BY` clause. This results in an invalid PostgreSQL query that throws a `Pr... | Can you confirm the following patch against master resolves your issue? diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py index c1a76584f0..6bd1471692 100644 --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -863,6 +863,9 @@ class ExpressionWrapper(Expression): ... | 2020-06-02T21:19:37Z | 3.2 | ["test_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_non_empty_group_by (expressions.tests.ExpressionWrapperTests)"] | ["test_aggregates (expressions.tests.ReprTests)", "test_distinct_aggregates (expressions.tests.ReprTests)", "test_expressions (expressions.tests.ReprTests)", "test_filtered_aggregates (expressions.tests.ReprTests)", "test_functions (expressions.tests.ReprTests)", "test_deconstruct (expressions.tests.FTests)", "test_dee... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
django/django | django__django-13109 | fbe82f82555bc25dccb476c749ca062f0b522be3 | diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -914,7 +914,7 @@ def validate(self, value, model_instance):
return
using = router.db_for_read(self.remote_field.model, instanc... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -28,8 +28,17 @@ def __repr__(self):
return self.__str__()
+class WriterManager(models.Manager):
+ def get_queryset(self):
+ qs = super().get_queryset()
+ ... | ## Issue Description
The Django `ForeignKey.validate()` method currently uses the model’s default manager (`_default_manager`) to validate foreign key references during form validation. This causes issues when a form or view intentionally uses a different manager (e.g., `Article._base_manager`) that exposes records no... | https://github.com/django/django/pull/12923
OK, yes, let's provisionally Accept this: I think it's probably correct. (At this level we're avoiding DB errors, not business logic errors, like "was this archived", which properly belong to the form layer...)
I take it the change here is ORM rather than forms per se.
I tak... | 2020-06-25T08:36:45Z | 3.2 | ["test_FK_validates_using_base_manager (validation.tests.BaseModelValidationTests)", "test_validate_foreign_key_to_model_with_overridden_manager (model_forms.tests.ModelFormBasicTests)"] | ["test_model_form_clean_applies_to_model (model_forms.tests.CustomCleanTests)", "test_override_clean (model_forms.tests.CustomCleanTests)", "test_setattr_raises_validation_error_field_specific (model_forms.tests.StrictAssignmentTests)", "test_setattr_raises_validation_error_non_field (model_forms.tests.StrictAssignment... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix |
django/django | django__django-13112 | 09914ccf688974e068941f55412b930729bafa06 | 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
@@ -582,7 +582,11 @@ def deconstruct(self):
if self.remote_field.parent_link:
kwargs['parent_link'] = self.remote_field.parent_link... | 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
@@ -867,6 +867,34 @@ class Meta:
with self.assertRaisesMessage(ValueError, msg):
project_state.apps
+ def test_reference_mixed_case_app_label(... | # Enhanced Problem Statement
## Issue Description
When running Django 3.1 beta with `makemigrations` or `migrate`, applications using mixed-case app names (e.g., `DJ_RegLogin`) and containing ForeignKeys referencing models within the same app fail during migration creation. The error occurs due to Django's internal h... | Thanks for the report. Regression in 9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502. Reproduced at fbe82f82555bc25dccb476c749ca062f0b522be3.
Potential fix: diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index d517d7269b..894d931d50 100644 --- a/django/db/models/fields/related.py +++ b/dj... | 2020-06-26T04:51:38Z | 3.2 | ["test_reference_mixed_case_app_label (migrations.test_state.StateTests)"] | ["test_abstract_model_children_inherit_indexes (migrations.test_state.ModelStateTests)", "test_bound_field_sanity_check (migrations.test_state.ModelStateTests)", "test_create_swappable (migrations.test_state.ModelStateTests)", "test_create_swappable_from_abstract (migrations.test_state.ModelStateTests)", "test_custom_m... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix |
django/django | django__django-13089 | 27c09043da52ca1f02605bf28600bfd5ace95ae4 | diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -267,9 +267,12 @@ def _cull(self, db, cursor, now):
cursor.execute(
connection.ops.cache_key_culling_sql() % table,
... | diff --git a/tests/cache/tests.py b/tests/cache/tests.py
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -621,6 +621,20 @@ def test_cull(self):
def test_zero_cull(self):
self._perform_cull_test('zero_cull', 50, 19)
+ def test_cull_delete_when_store_empty(self):
+ try:
+ cul... | ## Issue Description
The Django database cache backend (`django.core.cache.backends.db`) intermittently raises a `'NoneType' object is not subscriptable` error during cache entry culling. This issue occurs in the `_cull` method when attempting to access the result of a SQL query via `cursor.fetchone()[0]`, which can r... | 2020-06-20T07:36:10Z | 3.2 | ["test_cull_delete_when_store_empty (cache.tests.DBCacheTests)", "test_cull_delete_when_store_empty (cache.tests.DBCacheWithTimeZoneTests)"] | ["If None is cached, get() returns it instead of the default.", "Nonexistent cache keys return as None/default.", "set_many() returns an empty list when all keys are inserted.", "test_custom_key_validation (cache.tests.CustomCacheKeyValidationTests)", "test_long_vary_on (cache.tests.TestMakeTemplateFragmentKey)", "test... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | <15 min fix | |
django/django | django__django-13158 | 7af8f4127397279d19ef7c7899e93018274e2f9b | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -305,6 +305,7 @@ def clone(self):
obj.annotation_select_mask = None
else:
obj.annotation_select_mask = self.annotation_select_mask.copy... | diff --git a/tests/queries/test_qs_combinators.py b/tests/queries/test_qs_combinators.py
--- a/tests/queries/test_qs_combinators.py
+++ b/tests/queries/test_qs_combinators.py
@@ -51,6 +51,13 @@ def test_union_distinct(self):
self.assertEqual(len(list(qs1.union(qs2, all=True))), 20)
self.assertEqual(le... | # QuerySet.none() on Union QuerySets Returns Unexpected Results
## Issue Description
When using `QuerySet.union()` in Django's `ModelMultipleChoiceField`, submitting an empty form incorrectly associates *all* objects from the union queryset instead of none. This differs from the expected behavior when using `|` (OR) o... | Thanks for the report. QuerySet.none() doesn't work properly on combined querysets, it returns all results instead of an empty queryset. | 2020-07-06T19:18:11Z | 3.2 | ["test_union_none (queries.test_qs_combinators.QuerySetSetOperationTests)"] | ["test_combining_multiple_models (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_difference (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_intersection (queries.test_qs_combinators.QuerySetSetOperationTests)", "test_count_union (queries.test_qs_combinators.QuerySetSetOperati... | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | 15 min - 1 hour |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.