instance_id stringlengths 15 120 | repo stringclasses 45
values | base_commit stringlengths 40 40 | version stringlengths 1 7 | patch stringlengths 360 175k | test_patch stringlengths 372 61.3k | problem_statement stringlengths 55 14.9k | hints_text stringlengths 0 17.2k | FAIL_TO_PASS stringlengths 10 39k | PASS_TO_PASS stringlengths 2 271k | created_at stringdate 2017-07-06 11:03:14 2025-05-15 10:27:40 | difficulty stringclasses 4
values | environment_setup_commit stringclasses 51
values | run_script stringlengths 141 196 ⌀ | parsing_script stringlengths 145 200 ⌀ | before_repo_set_cmd stringlengths 198 4.71k ⌀ | selected_test_files_to_run stringlengths 10 6.75k ⌀ | image_name stringlengths 129 197 ⌀ | source stringclasses 3
values | language stringclasses 9
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
astropy__astropy-12907 | astropy/astropy | d16bfe05a744909de4b27f5875fe0d4ed41ce607 | 4.3 | 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]),
+ ... | Modeling's `separability_matrix` does not compute separability correctly for nested CompoundModels
Consider the following model:
```python
from astropy.modeling import models as m
from astropy.modeling.separable import separability_matrix
cm = m.Linear1D(10) & m.Linear1D(5)
```
It's separability matrix as y... | ["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]"... | 2022-03-03 15:14:54 | 15 min - 1 hour | 298ccb478e6bf092953bca67a3d29dc6c35f6752 | null | null | null | null | null | swebench_verified | py | |
astropy__astropy-13398 | astropy/astropy | 6500928dc0e57be8f06d1162eacc3ba5e2eff692 | 5.0 | 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... | A direct approach to ITRS to Observed transformations that stays within the ITRS.
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
Please be s... | 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... | ["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... | 2022-06-24 15:22:11 | 1-4 hours | cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 | null | null | null | null | null | swebench_verified | py |
astropy__astropy-13579 | astropy/astropy | 0df94ff7097961e92fd7812036a24b145bc13ca8 | 5.0 | 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... | Inconsistent behavior of `world_to_pixel` in `SlicedLowLevelWCS`
<!-- This comments are hidden when you submit the issue,
so you do not need to remove them! -->
<!-- Please be sure to check out our contributing guidelines,
https://github.com/astropy/astropy/blob/main/CONTRIBUTING.md .
Please be sure to check out... | 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 ... | ["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... | 2022-08-26 15:06:53 | 1-4 hours | cdf311e0714e611d48b0a31eb1f0e2cbffab7f23 | null | null | null | null | null | swebench_verified | py |
astropy__astropy-13977 | astropy/astropy | 5250b2442501e6c671c6b380536f1edb352602d1 | 5.1 | 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)
- ... | Should `Quantity.__array_ufunc__()` return `NotImplemented` instead of raising `ValueError` if the inputs are incompatible?
### Description
I'm trying to implement a duck type of `astropy.units.Quantity`. If you are interested, the project is available [here](https://github.com/Kankelborg-Group/named_arrays). I'm runn... | @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... | ["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... | 2022-11-01 22:24:58 | 15 min - 1 hour | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | null | null | null | null | null | swebench_verified | py |
astropy__astropy-14365 | astropy/astropy | 7269fa3e33e8d02485a647da91a5a2a60a06af61 | 5.1 | 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... | ascii.qdp Table format assumes QDP commands are upper case
### Description
ascii.qdp assumes that commands in a QDP file are upper case, for example, for errors they must be "READ SERR 1 2" whereas QDP itself is not case sensitive and case use "read serr 1 2".
As many QDP files are created by hand, the expectation... | 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... | ["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... | 2023-02-06 19:20:34 | 15 min - 1 hour | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | null | null | null | null | null | swebench_verified | py |
astropy__astropy-14369 | astropy/astropy | fa4e8d1cd279acf9b24560813c8652494ccd5922 | 5.1 | 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... | Incorrect units read from MRT (CDS format) files with astropy.table
### Description
When reading MRT files (formatted according to the CDS standard which is also the format recommended by AAS/ApJ) with `format='ascii.cds'`, astropy.table incorrectly parses composite units. According to CDS standard the units should be... | 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... | ["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... | 2023-02-06 21:56:51 | 1-4 hours | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | null | null | null | null | null | swebench_verified | py |
astropy__astropy-14508 | astropy/astropy | a3f4ae6cd24d5ecdf49f213d77b3513dd509a06c | 5.1 | 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")
... | `io.fits.Card` may use a string representation of floats that is larger than necessary
### Description
In some scenarios, `io.fits.Card` may use a string representation of floats that is larger than necessary, which can force comments to be truncated. Due to this, there are some keyword/value/comment combinations that... | 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 ... | ["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... | 2023-03-09 11:08:51 | 15 min - 1 hour | 5f74eacbcc7fff707a44d8eb58adaa514cb7dcb5 | null | null | null | null | null | swebench_verified | py |
astropy__astropy-14598 | astropy/astropy | 80c3854a5f4f4a6ab86c03d9db7854767fcd83c1 | 5.2 | 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 '... | Inconsistency in double single-quote ('') management in FITS Card
### Description
The management of single-quotes in FITS cards seem correct, except *sometimes* when dealing with null strings, i.e. double single quotes (`''`), which sometimes are transformed into single single quotes (`'`).
E.g.:
```python
In [... | 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 ... | ["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... | 2023-03-29 10:34:49 | 15 min - 1 hour | 362f6df12abf9bd769d4915fabf955c993ea22cf | null | null | null | null | null | swebench_verified | py |
astropy__astropy-7606 | astropy/astropy | 3cedd79e6c121910220f8e6df77c54a0b344ea94 | 1.3 | 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.
+... | Unit equality comparison with None raises TypeError for UnrecognizedUnit
```
In [12]: x = u.Unit('asdf', parse_strict='silent')
In [13]: x == None # Should be False
---------------------------------------------------------------------------
TypeError Traceback (most recent call la... | `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. | ["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:... | 2018-06-29 16:27:46 | 15 min - 1 hour | 848c8fa21332abd66b44efe3cb48b72377fb32cc | null | null | null | null | null | swebench_verified | py |
astropy__astropy-8707 | astropy/astropy | a85a0747c54bac75e9c3b2fe436b105ea029d6cf | 3.1 | 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... | Header.fromstring does not accept Python 3 bytes
According to [the docs](http://docs.astropy.org/en/stable/_modules/astropy/io/fits/header.html#Header.fromstring), the method `Header.fromstring` "...creates an HDU header from a byte string containing the entire header data."
By "byte string" here it really means the... | ["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... | 2019-05-15 13:21:19 | 15 min - 1 hour | 2e89d074b3b2abc2da80e437c93b1d5516a0ca57 | null | null | null | null | null | swebench_verified | py | |
django__django-10097 | django/django | b9cf764be62e77b4777b3a75ec256f6209a57671 | 2.2 | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -94,7 +94,7 @@ class URLValidator(RegexValidator):
regex = _lazy_re_compile(
r'^(?:[a-z0-9\.\-\+]*)://' # scheme is validated separately
- r'(?:\S+(?::\S*)?@)?' ... | diff --git a/tests/validators/invalid_urls.txt b/tests/validators/invalid_urls.txt
--- a/tests/validators/invalid_urls.txt
+++ b/tests/validators/invalid_urls.txt
@@ -57,3 +57,9 @@ http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
http://example.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | Make URLValidator reject invalid characters in the username and password
Description
(last modified by Tim Bell)
Since #20003, core.validators.URLValidator accepts URLs with usernames and passwords. RFC 1738 section 3.1 requires "Within the user and password field, any ":", "@", or "/" must be encoded"; however... | ["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... | 2018-06-26 23:30:51 | <15 min fix | 4fc35a9c3efdc9154efce28cb23cb84f8834517e | null | null | null | null | null | swebench_verified | py | |
django__django-10554 | django/django | 14d026cccb144c6877294ba4cd4e03ebf0842498 | 3.0 | 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 on ordering with derived querysets
Description
(last modified by Sergei Maertens)
May be related to #29692
Simple reproduction (the exact models are not relevant I think):
>>> Dimension.objects.values_list('id', flat=True)
<QuerySet [10, 11, 12, 13, 14, 15, 16, 17, 18]>
>>> q... | 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... | ["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... | 2018-10-24 14:24:45 | 1-4 hours | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-10914 | django/django | e7fd69d051eaa67cb17f172a39b57253e9cb831a | 3.0 | diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -304,7 +304,7 @@ def gettext_noop(s):
# The numeric mode to set newly-uploaded files to. The value should be a mode
# you'd pass directly to os.chmod; see https:/... | diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1099,7 +1099,7 @@ def test_override_file_upload_permissions(self):
the file_permissions_mode attribute of
django.core.files.storage.default_storage.
"""
- ... | Set default FILE_UPLOAD_PERMISSION to 0o644.
Description
Hello,
As far as I can see, the File Uploads documentation page does not mention any permission issues.
What I would like to see is a warning that in absence of explicitly configured FILE_UPLOAD_PERMISSIONS, the permissions for a file uploaded to FileSystemSto... | I think you're talking about ef70af77ec53160d5ffa060c1bdf5ed93322d84f (#28540). I guess the question is whether or not that documentation should be duplicated elsewhere.
Thank you Tim, this is precisely what I was looking for! I can only see one issue with the current docs (if you excuse me for bothering you with such ... | ["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... | 2019-01-30 13:13:20 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-10999 | django/django | 36300ef336e3f130a0dadc1143163ff3d23dc843 | 3.0 | 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)),
... | Fix parse_duration() for some negative durations
Description
The https://docs.djangoproject.com/en/2.1/_modules/django/utils/dateparse/ defines:
standard_duration_re = re.compile(
r'^'
r'(?:(?P<days>-?\d+) (days?, )?)?'
r'((?:(?P<hours>-?\d+):)(?=\d+:\d+))?'
r'(?:(?P<minutes>-?\d+):)?'
r'(?P<seconds>-?\d+)'
r'... | 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... | ["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... | 2019-02-16 07:44:50 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11087 | django/django | 8180ffba21bf10f4be905cb0d4890dc2bcff2788 | 3.0 | 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... | Optimize .delete() to use only required fields.
Description
Hi!
We're in the process of upgrading our Django 1.11 installation from Python 2.7 to Python 3.6, however are hitting an unexpected UnicodeDecodeError during a .delete() run by our daily data purging management command.
STR:
Have an existing Django 1.11 proj... | 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... | ["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... | 2019-03-16 22:59:57 | 15 min - 1 hour | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11095 | django/django | 7d49ad76562e8c0597a0eb66046ab423b12888d8 | 3.0 | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -327,6 +327,10 @@ def get_fieldsets(self, request, obj=None):
return self.fieldsets
return [(None, {'fields': self.get_fields(request, obj)}... | diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -429,3 +429,29 @@ class EpisodeAdmin(admin.ModelAdmin):
inlines = ma.get_inline_instances(request)
for (formset, inline), other_... | add ModelAdmin.get_inlines() hook to allow set inlines based on the request or model instance.
Description
add ModelAdmin.get_inlines() hook to allow set inlines based on the request or model instance.
Currently, We can override the method get_inline_instances to do such a thing, but a for loop should be copied to my... | Are you going to offer a patch to show exactly what you have in mind? I'm not immediately convinced that another hook is needed since the cost of duplicating a for loop is not that great.
If I want to realize a dynamic inlines based on the request or model instance. I need to override get_inline_instances to do it. Wha... | ["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... | 2019-03-19 15:17:28 | 15 min - 1 hour | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11133 | django/django | 879cc3da6249e920b8d54518a0ae06de835d7373 | 3.0 | 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):
+ ... | HttpResponse doesn't handle memoryview objects
Description
I am trying to write a BinaryField retrieved from the database into a HttpResponse. When the database is Sqlite this works correctly, but Postgresql returns the contents of the field as a memoryview object and it seems like current Django doesn't like this co... | 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 ... | ["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... | 2019-03-27 06:48:09 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11138 | django/django | c84b91b7603e488f7171fdff8f08368ef3d6b856 | 3.0 | 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... | TIME_ZONE value in DATABASES settings is not used when making dates timezone-aware on MySQL, SQLite, and Oracle.
Description
(last modified by Victor Talpaert)
(We assume the mysql backends)
I can set TIME_ZONE several times in settings.py, one for the global django app, and one for each database (see https://... | 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 | ["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... | 2019-03-28 13:11:56 | 1-4 hours | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11141 | django/django | 5d9cf79baf07fc4aed7ad1b06990532a65378155 | 3.1 | 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... | Allow migrations directories without __init__.py files
Description
(last modified by Tim Graham)
Background: In python 3 a package with no __init__.py is implicitly a namespace package, so it has no __file__ attribute.
The migrate command currently checks for existence of a __file__ attribute on the migrations... | ["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... | 2019-03-28 20:49:53 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py | |
django__django-11179 | django/django | 19fc6376ce67d01ca37a91ef2f55ef769f50513a | 3.0 | diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -277,6 +277,7 @@ def delete(self):
if self.can_fast_delete(instance):
with transaction.mark_for_rollback_on_error():
count ... | diff --git a/tests/delete/tests.py b/tests/delete/tests.py
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -1,6 +1,7 @@
from math import ceil
from django.db import IntegrityError, connection, models
+from django.db.models.deletion import Collector
from django.db.models.sql.constants import GET_ITERATOR_... | delete() on instances of models without any dependencies doesn't clear PKs.
Description
Deleting any model with no dependencies not updates the PK on the model. It should be set to None after .delete() call.
See Django.db.models.deletion:276-281. Should update the model line 280.
| Reproduced at 1ffddfc233e2d5139cc6ec31a4ec6ef70b10f87f. Regression in bc7dd8490b882b2cefdc7faf431dc64c532b79c9. Thanks for the report.
Regression test.
I have attached a simple fix which mimics what https://github.com/django/django/blob/master/django/db/models/deletion.py#L324-L326 does for multiple objects. I am not ... | ["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... | 2019-04-05 15:54:39 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11239 | django/django | d87bd29c4f8dfcdf3f4a4eb8340e6770a2416fe3 | 3.0 | diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -17,6 +17,10 @@ def runshell_db(cls, conn_params):
dbname = conn_params.get('database', '')
user = conn_params.g... | diff --git a/tests/dbshell/test_postgresql.py b/tests/dbshell/test_postgresql.py
--- a/tests/dbshell/test_postgresql.py
+++ b/tests/dbshell/test_postgresql.py
@@ -14,15 +14,16 @@ def _run_it(self, dbinfo):
That function invokes the runshell command, while mocking
subprocess.run(). It returns a 2-tuple... | Add support for postgresql client certificates and key to dbshell.
Description
This bug is very similar to the #28322
A common security procedure for DB access is to require mutual TLS for the DB connection.
This involves specifying a server certificate, client certificate, and client key when connecting.
Django alre... | ["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... | 2019-04-16 09:44:54 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py | |
django__django-11276 | django/django | 28d5262fa3315690395f04e3619ed554dbaf725b | 3.0 | 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... | Use Python stdlib html.escape() to in django.utils.html.escape()
Description
The function django.utils.html.escape() partially duplicates the Python stdlib function html.escape(). We can replace this duplication with wider community developed version.
html.escape() has been available since Python 3.2:
https://docs.p... | ["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... | 2019-04-24 12:35:05 | 15 min - 1 hour | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py | |
django__django-11299 | django/django | 6866c91b638de5368c18713fa851bfe56253ea55 | 3.0 | 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%')
... | CheckConstraint with OR operator generates incorrect SQL on SQLite and Oracle.
Description
(last modified by Michael Spallino)
Django is incorrectly including the fully qualified field name(e.g. “my_table”.”my_field”) in part of the check constraint. This only appears to happen when there is a combination of OR... | 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. | ["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.... | 2019-04-28 11:15:08 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11333 | django/django | 55b68de643b5c2d5f0a8ea7587ab3b2966021ccc | 3.0 | diff --git a/django/urls/base.py b/django/urls/base.py
--- a/django/urls/base.py
+++ b/django/urls/base.py
@@ -7,7 +7,7 @@
from django.utils.translation import override
from .exceptions import NoReverseMatch, Resolver404
-from .resolvers import get_ns_resolver, get_resolver
+from .resolvers import _get_cached_resol... | diff --git a/tests/urlpatterns/test_resolvers.py b/tests/urlpatterns/test_resolvers.py
--- a/tests/urlpatterns/test_resolvers.py
+++ b/tests/urlpatterns/test_resolvers.py
@@ -1,5 +1,6 @@
from django.test import SimpleTestCase
-from django.urls.resolvers import RegexPattern, RoutePattern
+from django.test.utils import ... | Optimization: Multiple URLResolvers may be unintentionally be constructed by calls to `django.urls.resolvers.get_resolver`
Description
Multiple URLResolvers may be constructed by django.urls.resolvers.get_resolver if django.urls.base.set_urlconf has not yet been called, resulting in multiple expensive calls to URLRes... | I'm planning to contribute a fix, as soon as I can get the CLA signed. Hi. Great. Happy to provisionally Accept this pending how the patch looks. (Sounds fine in principle.) Welcome on-board! :) | ["test_resolver_cache_default__root_urlconf (urlpatterns.test_resolvers.ResolverCacheTests)"] | ["test_str (urlpatterns.test_resolvers.RegexPatternTests)", "test_str (urlpatterns.test_resolvers.RoutePatternTests)"] | 2019-05-06 21:00:53 | 15 min - 1 hour | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11400 | django/django | 1f8382d34d54061eddc41df6994e20ee38c60907 | 3.0 | 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... | Ordering problem in admin.RelatedFieldListFilter and admin.RelatedOnlyFieldListFilter
Description
RelatedFieldListFilter doesn't fall back to the ordering defined in Model._meta.ordering.
Ordering gets set to an empty tuple in https://github.com/django/django/blob/2.2.1/django/contrib/admin/filters.py#L196 and unle... | 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 ... | ["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_... | 2019-05-22 11:30:39 | 1-4 hours | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11433 | django/django | 21b1d239125f1228e579b1ce8d94d4d5feadd2a6 | 3.0 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -48,8 +48,11 @@ def construct_instance(form, instance, fields=None, exclude=None):
continue
# Leave defaults for fields that aren't in POST data, except for
# checkbox... | diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -585,6 +585,32 @@ class Meta:
m2 = mf2.save(commit=False)
self.assertEqual(m2.mode, '')
+ def test_default_not_populated_on_non_empty_value_in_cleaned_data(sel... | Allow `cleaned_data` to overwrite fields' default values.
Description
See comments here: https://github.com/django/django/pull/7068/files#r289432409
Currently, when submitting a form, if 'some_field' isn't in the data payload (e.g. it wasn't included in the form, perhaps because its value is derived from another fie... | ["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... | 2019-05-31 17:06:20 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py | |
django__django-11603 | django/django | f618e033acd37d59b536d6e6126e6c5be18037f6 | 3.0 | 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... | Add DISTINCT support for Avg and Sum aggregates.
Description
As an extension of #28658, aggregates should be supported for other general aggregates such as Avg and Sum. Before 2.2, these aggregations just ignored the parameter, but now throw an exception.
This change would just involve setting these classes as allowi... | PR | ["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... | 2019-07-28 18:14:23 | <15 min fix | 419a78300f7cd27611196e1e464d50fd0385ff27 | null | null | null | null | null | swebench_verified | py |
django__django-11815 | django/django | e02f67ef2d03d48128e7a118bf75f0418e24e8ac | 3.1 | 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 ... | Migrations uses value of enum object instead of its name.
Description
(last modified by oasl)
When using Enum object as a default value for a CharField, the generated migration file uses the value of the Enum object instead of the its name. This causes a problem when using Django translation on the value of 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:... | ["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... | 2019-09-24 21:45:36 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-11820 | django/django | c2678e49759e5c4c329bff0eeca2886267005d21 | 3.1 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1708,9 +1708,15 @@ def _check_ordering(cls):
fld = None
for part in field.split(LOOKUP_SEP):
try:
- fld = _cls._meta.get_field(... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -814,6 +814,26 @@ class Meta:
)
])
+ def test_ordering_pointing_multiple_times_to_model_fields(... | models.E015 is raised when Meta.ordering contains "pk" of a related field.
Description
models.E015 is raised when Meta.ordering contains __pk of a related field, e.g.:
test_app.SomeModel: (models.E015) 'ordering' refers to the nonexistent field, related field, or lookup 'option__pk'.
Regression in 440505cb2cadbe1a5b9... | Regression test.
Thanks @felixxm for the test. I will prepare a fix for it. | ["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... | 2019-09-26 08:37:14 | <15 min fix | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-11848 | django/django | f0adf3b9b7a19cdee05368ff0c0c2d087f011180 | 3.1 | 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 check is incorrect
Description
(last modified by Ad Timmering)
RFC 850 does not mention this, but in RFC 7231 (and there's something similar in RFC 2822), there's the following quote:
Recipients of a timestamp value in rfc850-date format, which uses a
two-digit y... | 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 (... | ["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... | 2019-09-28 04:28:22 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-11964 | django/django | fc2b1cc926e34041953738e58fa6ad3053059b22 | 3.1 | 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 ... | The value of a TextChoices/IntegerChoices field has a differing type
Description
If we create an instance of a model having a CharField or IntegerField with the keyword choices pointing to IntegerChoices or TextChoices, the value returned by the getter of the field will be of the same type as the one created by enum.... | 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... | ["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... | 2019-10-23 14:16:45 | <15 min fix | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12039 | django/django | 58c1acb1d6054dfec29d0f30b1033bae6ef62aec | 3.1 | diff --git a/django/db/backends/ddl_references.py b/django/db/backends/ddl_references.py
--- a/django/db/backends/ddl_references.py
+++ b/django/db/backends/ddl_references.py
@@ -83,10 +83,14 @@ def __init__(self, table, columns, quote_name, col_suffixes=()):
def __str__(self):
def col_str(column, idx):... | diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py
--- a/tests/indexes/tests.py
+++ b/tests/indexes/tests.py
@@ -75,6 +75,22 @@ def test_index_together_single_list(self):
index_sql = connection.schema_editor()._model_indexes_sql(IndexTogetherSingleList)
self.assertEqual(len(index_sql), 1)
... | Use proper whitespace in CREATE INDEX statements
Description
(last modified by Hannes Ljungberg)
Creating an index through:
index = Index(
fields=['-name’],
name='idx'
)
Will generate the valid but not so pretty CREATE INDEX statement:
CREATE INDEX "idx" ON "schema_author" ("name"DESC)
The following would be... | PR: https://github.com/django/django/pull/12039
OK, I'll Accept this as a clean up (there's not actually an error right?). The patch looks small/clean enough at first glance.
Correct, no error. But since it's not documented as valid syntax to not have whitespace between the column and the ordering it could break in fu... | ["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... | 2019-11-06 21:14:34 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12050 | django/django | b93a0e34d9b9b99d41103782b7e7aeabf47517e3 | 3.1 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1059,21 +1059,10 @@ def resolve_lookup_value(self, value, can_reuse, allow_joins, simple_col):
elif isinstance(value, (list, tuple)):
# The items o... | diff --git a/tests/queries/test_query.py b/tests/queries/test_query.py
--- a/tests/queries/test_query.py
+++ b/tests/queries/test_query.py
@@ -113,3 +113,10 @@ def test_clone_select_related(self):
clone = query.clone()
clone.add_select_related(['note', 'creator__extra'])
self.assertEqual(quer... | Query.resolve_lookup_value coerces value of type list to tuple
Description
Changes introduced in #30687 cause an input value list to be coerced to tuple breaking exact value queries. This affects ORM field types that are dependent on matching input types such as PickledField.
The expected iterable return type should ... | ["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... | 2019-11-10 08:53:45 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py | |
django__django-12209 | django/django | 5a68f024987e6d16c2626a31bf653a2edddea579 | 3.1 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -849,6 +849,7 @@ def _save_table(self, raw=False, cls=None, force_insert=False,
updated = False
# Skip an UPDATE when adding an instance and primary key has a default.
... | diff --git a/tests/serializers/models/data.py b/tests/serializers/models/data.py
--- a/tests/serializers/models/data.py
+++ b/tests/serializers/models/data.py
@@ -4,6 +4,8 @@
NULL values, where allowed.
The basic idea is to have a model for each Django data type.
"""
+import uuid
+
from django.contrib.contenttypes.... | Change in behaviour when saving a model instance with an explcit pk value if the pk field has a default
Description
(last modified by Reupen Shah)
Consider the following model:
from uuid import uuid4
from django.db import models
class Sample(models.Model):
id = models.UUIDField(primary_key=True, default=uuid4)... | It looks like the logic in _save_table should not force an insert if an explicit pk value is provided. The logic should likely take pk_set into account if ( not pk_set and self._state.adding and self._meta.pk.default and self._meta.pk.default is not NOT_PROVIDED ): force_insert = True I'm surprised this was not caught... | ["partial(func, *args, **keywords) - new function with partial application"] | [] | 2019-12-12 04:11:05 | <15 min fix | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12273 | django/django | 927c903f3cd25c817c21738328b53991c035b415 | 3.1 | diff --git a/django/db/models/base.py b/django/db/models/base.py
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -569,6 +569,9 @@ def _get_pk_val(self, meta=None):
return getattr(self, meta.pk.attname)
def _set_pk_val(self, value):
+ for parent_link in self._meta.parents.values()... | diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -10,10 +10,11 @@
from .models import (
ArticleWithAuthor, BachelorParty, BirthdayParty, BusStation, Child,
- Derive... | Resetting primary key for a child model doesn't work.
Description
In the attached example code setting the primary key to None does not work (so that the existing object is overwritten on save()).
The most important code fragments of the bug example:
from django.db import models
class Item(models.Model):
# uid = mod... | I'm not sure if this is a bug. The test passes after adding self.item_ptr = None to Item.reset(). Is that the behavior you're looking for?
I agree with Tim here. It feels like what you're after is self.pk = None as it will be alias for self.item_ptr for Derived instances and self.uid for Item instances.
@Simon Charette... | ["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... | 2020-01-03 18:47:56 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12276 | django/django | 53d8646f799de7f92ab9defe9dc56c6125448102 | 3.1 | 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... | FileInput shouldn't display required attribute when initial data exists.
Description
(last modified by thenewguy)
I think that ClearableFileInput.use_required_attribute() (https://github.com/django/django/blob/e703b93a656b78b9b444bb3a9980e305ed002a70/django/forms/widgets.py#L454) should be moved to FileInput.u... | 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'... | ["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... | 2020-01-05 08:04:40 | <15 min fix | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12308 | django/django | 2e0f04507b17362239ba49830d26fec504d46978 | 3.1 | diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py
--- a/django/contrib/admin/utils.py
+++ b/django/contrib/admin/utils.py
@@ -398,6 +398,11 @@ def display_for_field(value, field, empty_value_display):
return formats.number_format(value)
elif isinstance(field, models.FileField) and... | diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py
--- a/tests/admin_utils/tests.py
+++ b/tests/admin_utils/tests.py
@@ -176,6 +176,23 @@ def test_null_display_for_field(self):
display_value = display_for_field(None, models.FloatField(), self.empty_value)
self.assertEqual(display_val... | JSONField are not properly displayed in admin when they are readonly.
Description
JSONField values are displayed as dict when readonly in the admin.
For example, {"foo": "bar"} would be displayed as {'foo': 'bar'}, which is not valid JSON.
I believe the fix would be to add a special case in django.contrib.admin.utils... | PR
The proposed patch is problematic as the first version coupled contrib.postgres with .admin and the current one is based off the type name which is brittle and doesn't account for inheritance. It might be worth waiting for #12990 to land before proceeding here as the patch will be able to simply rely of django.db.m... | ["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... | 2020-01-12 04:21:15 | <15 min fix | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12406 | django/django | 335c9c94acf263901fb023404408880245b0c4b4 | 3.1 | diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -980,6 +980,7 @@ def formfield(self, *, using=None, **kwargs):
'queryset': self.remote_field.model._default_manager.using(using),
... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -393,6 +393,9 @@ class Character(models.Model):
username = models.CharField(max_length=100)
last_action = models.DateTimeField()
+ def __str__(self):
+ retu... | ModelForm RadioSelect widget for foreign keys should not present a blank option if blank=False on the model
Description
Unlike the select widget, where a blank option is idiomatic even for required fields, radioselect has an inherent unfilled state that makes the "-------" option look suspiciously like a valid choice... | A pull request is available here: https://github.com/django/django/pull/11199
PR | ["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... | 2020-02-02 16:34:05 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12663 | django/django | fa5e7e46d875d4143510944f19d79df7b1739bab | 3.1 | 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... | Using SimpleLazyObject with a nested subquery annotation fails.
Description
(last modified by Jordan Ephron)
Prior to 35431298226165986ad07e91f9d3aca721ff38ec it was possible to use a SimpleLazyObject in a queryset as demonstrated below. This new behavior appears to be a regression.
Models
from django.contrib.a... | 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... | ["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... | 2020-04-04 18:58:49 | 15 min - 1 hour | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12708 | django/django | 447980e72ac01da1594dd3373a03ba40b7ee6f80 | 3.1 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -393,7 +393,12 @@ def alter_index_together(self, model, old_index_together, new_index_together):
news = {tuple(fields) for fields in new_index_to... | diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -62,7 +62,11 @@ def assertIndexExists(self, table, columns, value=True, using='default', index_t
any(
c["index"]
... | Migration crashes deleting an index_together if there is a unique_together on the same fields
Description
Happens with Django 1.11.10
Steps to reproduce:
1) Create models with 2 fields, add 2 same fields to unique_together and to index_together
2) Delete index_together -> Fail
It will fail at django/db/backends/base/... | Reproduced on master at 623139b5d1bd006eac78b375bcaf5948e695c3c6.
I haven't looked under the hood on this yet, but could it be related to the ordering of the operations generated for the mgiration? on first inspection it feels like this and #28862 could be caused by the same/similar underlying problem in how FieldRelat... | ["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... | 2020-04-12 22:20:59 | 1-4 hours | 0668164b4ac93a5be79f5b87fae83c657124d9ab | null | null | null | null | null | swebench_verified | py |
django__django-12754 | django/django | 18759b2209ff556aed7f20d83cbf23e3d234e41c | 3.2 | diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -563,6 +563,16 @@ def generate_created_models(self):
if isinstance(base, str) and "." in base:
base_app_... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -2454,3 +2454,28 @@ def test_mti_inheritance_model_removal(self):
self.assertNumberMigrations(changes, 'app', 1)
self.as... | FieldError when migrating field to new model subclass.
Description
Analogous to #21890. If creating a model subclass and moving a field onto it in the same step, makemigrations works but migrate dies with django.core.exceptions.FieldError: Local field 'title' in class 'Book' clashes with field of the same name from b... | Tentatively accepted for a future investigation. I'm not sure if this is feasible because detecting changes related with models' bases are tricky. Moreover you will lose data with such change, so IMO it's preferable to handle this manually.
Maybe the makemigrations could present some kind of info about the data being l... | ["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... | 2020-04-19 10:59:30 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13089 | django/django | 27c09043da52ca1f02605bf28600bfd5ace95ae4 | 3.2 | diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -267,9 +267,12 @@ def _cull(self, db, cursor, now):
cursor.execute(
connection.ops.cache_key_culling_sql() % table,
... | diff --git a/tests/cache/tests.py b/tests/cache/tests.py
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -621,6 +621,20 @@ def test_cull(self):
def test_zero_cull(self):
self._perform_cull_test('zero_cull', 50, 19)
+ def test_cull_delete_when_store_empty(self):
+ try:
+ cul... | cache.backends.db._cull sometimes fails with 'NoneType' object is not subscriptable
Description
(last modified by Guillermo Bonvehí)
I'm sporadically getting some cache errors using database backend.
The error is: 'NoneType' object is not subscriptable
And the backtrace:
/usr/local/lib/python3.7/site-packages/d... | ["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... | 2020-06-20 07:36:10 | <15 min fix | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py | |
django__django-13128 | django/django | 2d67222472f80f251607ae1b720527afceba06ad | 3.2 | 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
@@ -443,23 +443,6 @@ def set_source_expressions(self, exprs):
self.lhs, self.rhs = exprs
def as_sql(self, compiler, connection):
- try:
- ... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -1493,9 +1493,7 @@ def test_duration_expressions(self):
@skipUnlessDBFeature('supports_temporal_subtraction')
def test_date_subtraction(self):
queryset = Experimen... | make temporal subtraction work without ExpressionWrapper
Description
class Experiment(models.Model):
start = models.DateTimeField()
end = models.DateTimeField()
Experiment.objects.annotate(
delta=F('end') - F('start') + Value(datetime.timedelta(), output_field=DurationField())
)
This gives:
django.core.exceptions.... | ["test_date_case_subtraction (expressions.tests.FTimeDeltaTests)", "test_date_subquery_subtraction (expressions.tests.FTimeDeltaTests)", "test_date_subtraction (expressions.tests.FTimeDeltaTests)", "test_datetime_subquery_subtraction (expressions.tests.FTimeDeltaTests)", "test_datetime_subtraction_microseconds (express... | ["test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_equal_Value (expressions.tests.FTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTest... | 2020-06-30 18:06:56 | 1-4 hours | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py | |
django__django-13212 | django/django | f4e93919e4608cfc50849a1f764fd856e0917401 | 3.2 | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -48,7 +48,7 @@ def __call__(self, value):
regex_matches = self.regex.search(str(value))
invalid_input = regex_matches if self.inverse_match else not regex_matches
... | diff --git a/tests/forms_tests/tests/test_validators.py b/tests/forms_tests/tests/test_validators.py
--- a/tests/forms_tests/tests/test_validators.py
+++ b/tests/forms_tests/tests/test_validators.py
@@ -1,9 +1,11 @@
import re
+import types
from unittest import TestCase
from django import forms
from django.core im... | Make validators include the provided value in ValidationError
Description
It is sometimes desirable to include the provide value in a custom error message. For example:
“blah” is not a valid email.
By making built-in validators provide value to ValidationError, one can override an error message and use a %(value)s pl... | https://github.com/django/django/pull/13212
After reconsideration I have some doubts. Do you think it's really useful to include invalid values in error messages? Invalid form is redisplayed with errors in most (all?) of cases, so I'm not sure if it can be useful to display error messages containing invalid values nex... | ["test_value_placeholder_with_char_field (forms_tests.tests.test_validators.ValidatorCustomMessageTests)", "test_value_placeholder_with_decimal_field (forms_tests.tests.test_validators.ValidatorCustomMessageTests)", "test_value_placeholder_with_file_field (forms_tests.tests.test_validators.ValidatorCustomMessageTests)"... | ["test_all_errors_get_reported (forms_tests.tests.test_validators.TestFieldWithValidators)", "test_field_validators_can_be_any_iterable (forms_tests.tests.test_validators.TestFieldWithValidators)"] | 2020-07-21 02:53:58 | 1-4 hours | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13315 | django/django | 36bc47069ce071e80c8129500de3b8664d2058a7 | 3.2 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -97,10 +97,18 @@ def model_to_dict(instance, fields=None, exclude=None):
def apply_limit_choices_to_to_formfield(formfield):
"""Apply limit_choices_to to the formfield's queryset if needed."... | diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -411,9 +411,14 @@ class StumpJoke(models.Model):
Character,
models.CASCADE,
limit_choices_to=today_callable_dict,
- related_name="+",
+ r... | limit_choices_to on a ForeignKey can render duplicate options in formfield
Description
If you pass a Q object as limit_choices_to on a ForeignKey field involving a join, you may end up with duplicate options in your form.
See regressiontest in patch for a clear view on the problem.
| Replying to SmileyChris: I've updated the patch to resolve the conflicts I've had since you flagged this one as "Ready for checkin". No real change.
update resolving conflict
Is there something I can do to get this checked in? I re-read the Triage docs. As far as I can see "A developer checks in the fix" is the only s... | ["test_limit_choices_to_no_duplicates (model_forms.tests.LimitChoicesToTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "test_bad_callback (model_forms.tests.FormFieldCallbackTests)", "Regression for #13095: Using base forms with widgets defined in Meta should not raise errors.", "A custom formfield_callback is used if provided", "Regression for #15315: mod... | 2020-08-17 04:24:39 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13343 | django/django | ece18207cbb64dd89014e279ac636a6c9829828e | 3.2 | diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -229,6 +229,8 @@ def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **k
self.storage = storage or default_storage
... | diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -29,7 +29,9 @@
from django.urls import NoReverseMatch, reverse_lazy
from django.utils import timezone
-from .models import Storage, temp_storage, temp_storage_location
+from ... | FileField with a callable storage does not deconstruct properly
Description
A FileField with a callable storage parameter should not actually evaluate the callable when it is being deconstructed.
The documentation for a FileField with a callable storage parameter, states:
You can use a callable as the storage paramet... | ["test_deconstruction (file_storage.tests.FieldCallableFileStorageTests)"] | ["test_get_filesystem_storage (file_storage.tests.GetStorageClassTests)", "test_get_invalid_storage_module (file_storage.tests.GetStorageClassTests)", "test_get_nonexistent_storage_class (file_storage.tests.GetStorageClassTests)", "test_get_nonexistent_storage_module (file_storage.tests.GetStorageClassTests)", "test_ca... | 2020-08-24 19:29:12 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py | |
django__django-13344 | django/django | e39e727ded673e74016b5d3658d23cbe20234d11 | 3.2 | diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py
--- a/django/contrib/sessions/middleware.py
+++ b/django/contrib/sessions/middleware.py
@@ -13,9 +13,7 @@ class SessionMiddleware(MiddlewareMixin):
# RemovedInDjango40Warning: when the deprecation ends, replace with:
# ... | diff --git a/tests/cache/tests.py b/tests/cache/tests.py
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -2083,6 +2083,7 @@ def test_constructor(self):
self.assertEqual(middleware.cache_timeout, 30)
self.assertEqual(middleware.key_prefix, 'middlewareprefix')
self.assertEqual(middlewa... | Coroutine passed to the first middleware's process_response() instead of HttpResponse.
Description
Like the title says, using ASGI (+ uvicorn in my case), the first middleware (according to the list in settings.py) receives a coroutine as its response parameter, while all other middlewares down the line receive a dja... | Tentatively accepted for investigation. It's not about the first middleware because if you have only one it gets HttpResponse, but if you have at least two then then the first in a chain gets coroutine. Andrew, Can you take a look?
I think it's a bug in SecurityMiddleware : its __init__ does not call super().__init__()... | ["test_coroutine (deprecation.test_middleware_mixin.MiddlewareMixinTests)", "test_deprecation (deprecation.test_middleware_mixin.MiddlewareMixinTests)"] | ["Nonexistent cache keys return as None/default.", "set_many() returns an empty list when all keys are inserted.", "test_createcachetable_observes_database_router (cache.tests.CreateCacheTableForDBCacheTests)", "test_per_thread (cache.tests.CacheHandlerTest)", "test_same_instance (cache.tests.CacheHandlerTest)", "If No... | 2020-08-24 20:50:35 | 1-4 hours | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13346 | django/django | 9c92924cd5d164701e2514e1c2d6574126bd7cc2 | 3.2 | diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py
--- a/django/db/models/fields/json.py
+++ b/django/db/models/fields/json.py
@@ -378,6 +378,30 @@ def as_sqlite(self, compiler, connection):
return super().as_sql(compiler, connection)
+class KeyTransformIn(lookups.In):
+ def ... | diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py
--- a/tests/model_fields/test_jsonfield.py
+++ b/tests/model_fields/test_jsonfield.py
@@ -627,6 +627,25 @@ def test_key_iexact(self):
self.assertIs(NullableJSONModel.objects.filter(value__foo__iexact='BaR').exists(), True)... | On MySQL, Oracle, and SQLite, __in lookup doesn't work on key transforms.
Description
I am currently rewriting our app where we will start using models.JSONField instead of django_mysql.models.JSONField. I noticed that the __in operator is not reacting the same way is it does on other fields.
first_filter = {‘our_fie... | Thanks for this ticket, however I cannot reproduce this issue. I tried with the following test and it works for me (also on MySQL): diff --git a/tests/model_fields/test_jsonfield.py b/tests/model_fields/test_jsonfield.py index a7648711ac..97d79e5bee 100644 --- a/tests/model_fields/test_jsonfield.py +++ b/tests/model_fi... | ["test_key_in (model_fields.test_jsonfield.TestQuerying)", "test_key_iregex (model_fields.test_jsonfield.TestQuerying)"] | ["test_formfield (model_fields.test_jsonfield.TestFormField)", "test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)", "test_custom_encoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_decoder (model_fields.test_jsonfield.TestValidation)", "test_invalid_encoder (model_fields... | 2020-08-25 06:25:31 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13363 | django/django | 76e0151ea0e0f56dca66cee846a78b89346d2c4c | 3.2 | diff --git a/django/db/models/functions/datetime.py b/django/db/models/functions/datetime.py
--- a/django/db/models/functions/datetime.py
+++ b/django/db/models/functions/datetime.py
@@ -292,7 +292,7 @@ class TruncDate(TruncBase):
def as_sql(self, compiler, connection):
# Cast to date rather than truncate... | diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py
--- a/tests/db_functions/datetime/test_extract_trunc.py
+++ b/tests/db_functions/datetime/test_extract_trunc.py
@@ -1124,14 +1124,24 @@ def test_trunc_timezone_applied_before_truncation(self):
mod... | Add support for tzinfo parameter to TruncDate() and TruncTime().
Description
(last modified by Joe Jackson)
Description
TruncDate inherits from TruncBase, which includes the TimeZone mixin. This should allow a developer to pass in a tzinfo object to be used when converting TruncDate, but it actually uses the re... | Please check https://code.djangoproject.com/ticket/31640 Is it related to your issue?
Replying to Serhii Romanov: Please check https://code.djangoproject.com/ticket/31640 Is it related to your issue? It is related, but not exactly my issue. That patch updates the TruncBase as_sql method, and world work. But the TruncDa... | ["test_trunc_timezone_applied_before_truncation (db_functions.datetime.test_extract_trunc.DateFunctionWithTimeZoneTests)"] | ["test_extract_day_func (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_unsupported_lookups (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extract_duration_without_native_duration_field (db_functions.datetime.test_extract_trunc.DateFunctionTests)", "test_extra... | 2020-08-29 18:59:41 | <15 min fix | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13410 | django/django | 580a4341cb0b4cbfc215a70afc004875a7e815f4 | 3.2 | diff --git a/django/core/files/locks.py b/django/core/files/locks.py
--- a/django/core/files/locks.py
+++ b/django/core/files/locks.py
@@ -107,9 +107,12 @@ def unlock(f):
return True
else:
def lock(f, flags):
- ret = fcntl.flock(_fd(f), flags)
- return ret == 0
+ ... | diff --git a/tests/files/tests.py b/tests/files/tests.py
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -8,7 +8,7 @@
from pathlib import Path
from unittest import mock
-from django.core.files import File
+from django.core.files import File, locks
from django.core.files.base import ContentFile
from djang... | Bug in posix implementation of django/core/files/locks.py
Description
The posix version of locks (the version which supports import fcntl) has a bug. The code attempts to return True to indicate success or failure acquiring a lock, but instead it always returns False. The reason is that cpython fcntl module returns N... | Thanks for the ticket. Would you like to prepare a pull request? (tests are also required). | ["test_exclusive_lock (files.tests.FileTests)", "test_shared_lock (files.tests.FileTests)"] | ["test_open_resets_file_to_start_and_returns_context_manager (files.tests.InMemoryUploadedFileTests)", "test_content_file_custom_name (files.tests.ContentFileTestCase)", "test_content_file_default_name (files.tests.ContentFileTestCase)", "test_content_file_input_type (files.tests.ContentFileTestCase)", "test_open_reset... | 2020-09-11 09:58:41 | <15 min fix | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13513 | django/django | 6599608c4d0befdcb820ddccce55f183f247ae4f | 3.2 | diff --git a/django/views/debug.py b/django/views/debug.py
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -394,19 +394,19 @@ def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, mod
return None, [], None, []
return lower_bound, pre_context, context_line, post_co... | diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -467,6 +467,34 @@ def test_suppressed_context(self):
self.assertIn('<p>Request data not supplied</p>', html)
self.assertNotI... | debug error view doesn't respect exc.__suppress_context__ (PEP 415)
Description
Consider the following view that raises an exception:
class TestView(View):
def get(self, request, *args, **kwargs):
try:
raise RuntimeError('my error')
except Exception as exc:
raise ValueError('my new error') from None
Even t... | Here is a related (but different) issue about the traceback shown by the debug error view ("debug error view shows no traceback if exc.traceback is None for innermost exception"): https://code.djangoproject.com/ticket/31672
Thanks Chris. Would you like to prepare a patch?
PR: https://github.com/django/django/pull/1317... | ["test_innermost_exception_without_traceback (view_tests.tests.test_debug.ExceptionReporterTests)"] | ["test_sensitive_post_parameters_not_called (view_tests.tests.test_debug.DecoratorsTests)", "test_sensitive_variables_not_called (view_tests.tests.test_debug.DecoratorsTests)", "test_repr (view_tests.tests.test_debug.CallableSettingWrapperTests)", "test_cleansed_substitute_override (view_tests.tests.test_debug.CustomEx... | 2020-10-08 14:07:33 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13551 | django/django | 7f9e4524d6b23424cf44fbe1bf1f4e70f6bb066e | 3.2 | diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
--- a/django/contrib/auth/tokens.py
+++ b/django/contrib/auth/tokens.py
@@ -78,9 +78,9 @@ def _make_token_with_timestamp(self, user, timestamp, legacy=False):
def _make_hash_value(self, user, timestamp):
"""
- Hash the use... | diff --git a/tests/auth_tests/models/__init__.py b/tests/auth_tests/models/__init__.py
--- a/tests/auth_tests/models/__init__.py
+++ b/tests/auth_tests/models/__init__.py
@@ -8,6 +8,7 @@
from .no_password import NoPasswordUser
from .proxy import Proxy, UserProxy
from .uuid_pk import UUIDUser
+from .with_custom_email... | Changing user's email could invalidate password reset tokens
Description
Sequence:
Have account with email address foo@…
Password reset request for that email (unused)
foo@… account changes their email address
Password reset email is used
The password reset email's token should be rejected at that point, but in fact ... | ["Updating the user email address invalidates the token.", "test_token_with_different_secret (auth_tests.test_tokens.TokenGeneratorTest)"] | ["test_str (auth_tests.test_models.GroupTests)", "test_group_natural_key (auth_tests.test_models.NaturalKeysTestCase)", "test_user_natural_key (auth_tests.test_models.NaturalKeysTestCase)", "test_check_password (auth_tests.test_models.AnonymousUserTests)", "test_delete (auth_tests.test_models.AnonymousUserTests)", "tes... | 2020-10-17 17:22:01 | <15 min fix | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py | |
django__django-13569 | django/django | 257f8495d6c93e30ab0f52af4c488d7344bcf112 | 3.2 | diff --git a/django/db/models/functions/math.py b/django/db/models/functions/math.py
--- a/django/db/models/functions/math.py
+++ b/django/db/models/functions/math.py
@@ -154,6 +154,9 @@ def as_oracle(self, compiler, connection, **extra_context):
def as_sqlite(self, compiler, connection, **extra_context):
... | diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -1315,3 +1315,18 @@ def test_aggregation_subquery_annotation_related_field(self):
# with self.assertNumQueries(1) as ctx:
# self.assertSequenceEqual(books_qs, [... | order_by('?') unexpectedly breaking queryset aggregation
Description
Steps to reproduce:
class Thing(models.Model):
pass
class Related(models.Model):
models.ForeignKey(Thing)
With data
t = Thing.objects.create()
rs = [Related.objects.create(thing=t) for _ in range(2)]
The following query works as expected. The aggr... | Patch to SQLCompiler.get_group_by that excluds Random expressions
PR
I wonder what would happen if we skipped all expressions that have no cols as source expressions (plus, we need to include any raw sql).
I wonder what would happen if we skipped all expressions that have no cols as source expressions (plus, we need t... | ["Random() is not included in the GROUP BY when used for ordering."] | ["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.AggregateTestCase)", "test_aggregate_over_aggregate (aggregation.tests.Aggre... | 2020-10-19 21:20:55 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13590 | django/django | 755dbf39fcdc491fe9b588358303e259c7750be4 | 3.2 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -1077,10 +1077,14 @@ def resolve_lookup_value(self, value, can_reuse, allow_joins):
elif isinstance(value, (list, tuple)):
# The items of the iterab... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -2,6 +2,7 @@
import pickle
import unittest
import uuid
+from collections import namedtuple
from copy import deepcopy
from decimal import Decimal
from unittest import mock
@@ -8... | Upgrading 2.2>3.0 causes named tuples used as arguments to __range to error.
Description
I noticed this while upgrading a project from 2.2 to 3.0.
This project passes named 2-tuples as arguments to range queryset filters. This works fine on 2.2. On 3.0 it causes the following error: TypeError: __new__() missing 1 req... | ["test_range_lookup_namedtuple (expressions.tests.IterableLookupInnerExpressionsTests)"] | ["test_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_non_empty_group_by (expressions.tests.ExpressionWrapperTests)", "test_deconstruct (expressions.tests.FTests)", "test_deepcopy (expressions.tests.FTests)", "test_equal (expressions.tests.FTests)", "test_hash (expressions.tests.FTests)", "test_not_e... | 2020-10-23 09:34:55 | 15 min - 1 hour | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py | |
django__django-13794 | django/django | fe886eee36be8022f34cfe59aa61ff1c21fe01d9 | 3.2 | diff --git a/django/utils/functional.py b/django/utils/functional.py
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -176,6 +176,12 @@ def __mod__(self, rhs):
return str(self) % rhs
return self.__cast() % rhs
+ def __add__(self, other):
+ return sel... | diff --git a/tests/template_tests/filter_tests/test_add.py b/tests/template_tests/filter_tests/test_add.py
--- a/tests/template_tests/filter_tests/test_add.py
+++ b/tests/template_tests/filter_tests/test_add.py
@@ -2,6 +2,7 @@
from django.template.defaultfilters import add
from django.test import SimpleTestCase
+fr... | add filter is unable to concatenate strings with lazy string
Description
If you try to concatenate a string with a lazy string with the add template filter, the result is always the empty string because the add filter generates an exception (TypeError: can only concatenate str (not "__proxy__") to str).
| Tests.
Thanks. I attached a test. | ["test_lazy_add (utils_tests.test_functional.FunctionalTests)", "test_add08 (template_tests.filter_tests.test_add.AddTests)", "test_add09 (template_tests.filter_tests.test_add.AddTests)"] | ["test_add (template_tests.filter_tests.test_add.FunctionTests)", "cached_property caches its value and behaves like a property.", "test_cached_property_auto_name (utils_tests.test_functional.FunctionalTests)", "Disallow this case because the decorated function wouldn't be cached.", "test_cached_property_reuse_same_nam... | 2020-12-19 20:09:34 | <15 min fix | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13807 | django/django | 89fc144dedc737a79929231438f035b1d4a993c9 | 3.2 | diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -327,19 +327,24 @@ def check_constraints(self, table_names=None):
violations = cursor.execute('PRAGMA foreign_key_check').fetchal... | diff --git a/tests/backends/models.py b/tests/backends/models.py
--- a/tests/backends/models.py
+++ b/tests/backends/models.py
@@ -140,3 +140,11 @@ class Author(models.Model):
class Book(models.Model):
author = models.ForeignKey(Author, models.CASCADE, to_field='name')
+
+
+class SQLKeywordsModel(models.Model):... | loaddata crashes on SQLite when table names are SQL keywords.
Description
Steps to reproduce:
Create a Model called Order. (order is a SQL reserved word)
Create fixtures for the model
Use manage.py loaddata to load the fixture.
Notice that it fails with the following error. This is because the table name order is not... | Thanks for the report, I was able to reproduce this issue with db_table = 'order'. Reproduced at 966b5b49b6521483f1c90b4499c4c80e80136de3.
Simply wrapping table_name in connection.ops.quote_name should address the issue for anyone interested in picking the issue up.
a little guidance needed as this is my first ticket.
... | ["test_check_constraints_sql_keywords (backends.tests.FkConstraintsTests)"] | ["Sequence names are correct when resetting generic relations (Ref #13941)", "test_parameter_escaping (backends.tests.EscapingChecks)", "test_paramless_no_escaping (backends.tests.EscapingChecks)", "An executemany call with too many/not enough parameters will raise an exception (Refs #12612)", "test_paramless_no_escapi... | 2020-12-23 21:09:32 | <15 min fix | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py |
django__django-13809 | django/django | bef6f7584280f1cc80e5e2d80b7ad073a93d26ec | 4.0 | diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
--- a/django/core/management/commands/runserver.py
+++ b/django/core/management/commands/runserver.py
@@ -51,6 +51,10 @@ def add_arguments(self, parser):
'--noreload', action='store_false', dest='use_re... | diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1313,6 +1313,29 @@ def test_readonly_database(self):
# You have # ...
self.assertIn('unapplied migration(s)', self.output.getvalue())
+ @mock.patch('d... | Add --skip-checks option to the runserver command.
Description
Rationale:
It would be consistent with other management commands performing system checks
It would help people like me who would rather have checks enabled exclusively in CI/CD than wait 15-20 seconds for each project reload during development
Related Sta... | Sounds reasonable.
PR | ["test_skip_checks (admin_scripts.tests.ManageRunserver)"] | ["test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_ex... | 2020-12-24 15:31:35 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-13837 | django/django | 415f50298f97fb17f841a9df38d995ccf347dfcc | 3.2 | diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -216,14 +216,14 @@ def get_child_arguments():
executable is reported to not have the .exe extension which can cause bugs
on reloading.
"""
- import django.__main__
... | diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -23,6 +23,7 @@
from django.utils import autoreload
from django.utils.autoreload import WatchmanUnavailable
+from .test_module import __mai... | Allow autoreloading of `python -m pkg_other_than_django runserver`
Description
(last modified by William Schwartz)
django.utils.autoreload.get_child_arguments detects if Python was launched as python -m django. Currently it detects only when -m was passed specifically django (and only in Python environments i... | ["test_run_as_non_django_module (utils_tests.test_autoreload.TestChildArguments)"] | ["test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception_with_context (utils_tests.test_autoreload.TestRaiseLastExce... | 2021-01-04 17:44:23 | 1-4 hours | 65dfb06a1ab56c238cc80f5e1c31f61210c4577d | null | null | null | null | null | swebench_verified | py | |
django__django-14007 | django/django | 619f26d2895d121854b1bed1b535d42b722e2eba | 4.0 | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1405,6 +1405,7 @@ def execute_sql(self, returning_fields=None):
returning_fields and len(self.query.objs) != 1 and
not self.connect... | diff --git a/tests/custom_pk/fields.py b/tests/custom_pk/fields.py
--- a/tests/custom_pk/fields.py
+++ b/tests/custom_pk/fields.py
@@ -20,7 +20,7 @@ def __eq__(self, other):
return self.value == other
-class MyAutoField(models.CharField):
+class MyWrapperField(models.CharField):
def __init__(self, *... | Database converters (from_db_value) not called for returning_fields on insert
Description
Making a subclass of BigAutoField, I've found that, unlike all other query pathways, on insert the returned integer is not passed through any database converters defined for the field - including the from_db_value hook.
This mea... | ["test_auto_field_subclass_create (custom_pk.tests.CustomPKTests)"] | ["Get can accept pk or the real attribute name", "Custom pks work with in_bulk, both for integer and non-integer types", "pk and attribute name are available on the model", "Both pk and custom attribute_name can be used in filter and friends", "Custom pk doesn't affect related_name based lookups", "Queries across table... | 2021-02-13 09:00:02 | 1-4 hours | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py | |
django__django-14011 | django/django | e4430f22c8e3d29ce5d9d0263fba57121938d06d | 4.0 | diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -16,6 +16,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.core.handlers.wsgi import LimitedStream
from django.core.wsgi import get_wsg... | diff --git a/django/test/testcases.py b/django/test/testcases.py
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1513,11 +1513,12 @@ def run(self):
finally:
connections.close_all()
- def _create_server(self):
+ def _create_server(self, connections_override=None):
... | LiveServerTestCase's ThreadedWSGIServer doesn't close database connections after each thread
Description
In Django 2.2.17, I'm seeing the reappearance of #22414 after it was fixed in 1.11. #22414 is the issue where the following error will occur at the conclusion of a test run when destroy_test_db() is called:
Operat... | I wonder if this issue is because ThreadingMixIn creates a new thread for each request, but those threads don't close their database connections at their conclusion, e.g. like LiveServerThread does. Here is the code in CPython for ThreadingMixIn's process_request() and server_close(): https://github.com/python/cpython... | ["test_live_server_url_is_class_property (servers.tests.LiveServerAddress)", "Data written to the database by a view can be read.", "Fixtures are properly loaded and visible to the live server thread.", "test_check_model_instance_from_subview (servers.tests.LiveServerThreadedTests)", "test_view_calls_subview (servers.t... | ["test_set_up_class (servers.tests.LiveServerTestCaseSetupTest)", "Contrast to"] | 2021-02-15 06:15:21 | 1-4 hours | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14034 | django/django | db1fc5cd3c5d36cdb5d0fe4404efd6623dd3e8fb | 4.0 | diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -2,7 +2,7 @@
from django.core.exceptions import ValidationError
from django.forms.utils import flatatt, pretty_name
-from django.forms.widgets import Textarea, TextInput
+from dj... | diff --git a/tests/forms_tests/field_tests/test_multivaluefield.py b/tests/forms_tests/field_tests/test_multivaluefield.py
--- a/tests/forms_tests/field_tests/test_multivaluefield.py
+++ b/tests/forms_tests/field_tests/test_multivaluefield.py
@@ -10,6 +10,20 @@
beatles = (('J', 'John'), ('P', 'Paul'), ('G', 'George'),... | MultiValueField ignores a required value of a sub field
Description
(last modified by Takayuki Hirai)
A field and a form definition:
from django.forms import (
Form,
CharField,
MultiValueField,
MultiWidget,
)
class MF(MultiValueField):
widget = MultiWidget
def __init__(self):
fields = [
CharField(req... | Why do you pass required=False in super(MF, self).__init__()? Removing that seems to resolve the issue.
I tried to remove required=False, then both INPUT elements in HTML became required. <tr><th><label for="id_mf_0">Mf:</label></th><td><input type="text" name="mf_0" required id="id_mf_0" /> <input type="text" name="mf... | ["test_render_required_attributes (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)"] | ["test_bad_choice (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_clean (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_clean_disabled_multivalue (forms_tests.field_tests.test_multivaluefield.MultiValueFieldTest)", "test_disabled_has_changed (forms_tests.field_tests... | 2021-02-22 19:32:50 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14089 | django/django | d01709aae21de9cd2565b9c52f32732ea28a2d98 | 4.0 | diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -25,6 +25,9 @@ def discard(self, item):
def __iter__(self):
return iter(self.dict)
+ def __reversed__(self):
+ return reversed(self.dict)
+
... | diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py
--- a/tests/utils_tests/test_datastructures.py
+++ b/tests/utils_tests/test_datastructures.py
@@ -1,7 +1,7 @@
"""
Tests for stuff in django.utils.datastructures.
"""
-
+import collections.abc
import copy
import pickle
... | Allow calling reversed() on an OrderedSet
Description
Currently, OrderedSet isn't reversible (i.e. allowed to be passed as an argument to Python's reversed()). This would be natural to support given that OrderedSet is ordered. This should be straightforward to add by adding a __reversed__() method to OrderedSet.
| ["test_reversed (utils_tests.test_datastructures.OrderedSetTests)"] | ["test_copy (utils_tests.test_datastructures.CaseInsensitiveMappingTests)", "test_create_with_invalid_key (utils_tests.test_datastructures.CaseInsensitiveMappingTests)", "test_create_with_invalid_values (utils_tests.test_datastructures.CaseInsensitiveMappingTests)", "test_del (utils_tests.test_datastructures.CaseInsens... | 2021-03-06 20:51:08 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py | |
django__django-14122 | django/django | bc04941bf811d1ea2c79fb7fc20457ed2c7e3410 | 4.0 | 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
@@ -125,11 +125,12 @@ def get_group_by(self, select, order_by):
cols = expr.get_group_by_cols()
for col in cols:
expre... | diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py
--- a/tests/ordering/tests.py
+++ b/tests/ordering/tests.py
@@ -2,7 +2,7 @@
from operator import attrgetter
from django.db.models import (
- CharField, DateTimeField, F, Max, OuterRef, Subquery, Value,
+ CharField, Count, DateTimeField, F, Max, Ou... | Meta.ordering fields must not be included in GROUP BY clause
Description
This continues (closed) [1] ticket.
I beleave it was not properly fixed in commit [0ddb4ebf].
While commit [0ddb4ebf] removes ORDER BY when Meta.ordering is used it still does populates GROUP BY with Meta.ordering fields thus leads to wrong aggr... | ["test_default_ordering_does_not_affect_group_by (ordering.tests.OrderingTests)"] | ["By default, Article.objects.all() orders by pub_date descending, then", "F expressions can be used in Meta.ordering.", "Override ordering with order_by, which is in the same format as the", "Ordering can be based on fields included from an 'extra' clause", "If the extra clause uses an SQL keyword for a name, it will ... | 2021-03-13 19:57:16 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py | |
django__django-14155 | django/django | 2f13c476abe4ba787b6cb71131818341911f43cc | 4.0 | diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py
--- a/django/urls/resolvers.py
+++ b/django/urls/resolvers.py
@@ -59,9 +59,16 @@ def __getitem__(self, index):
return (self.func, self.args, self.kwargs)[index]
def __repr__(self):
- return "ResolverMatch(func=%s, args=%s, kwargs=%s... | diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
--- a/tests/urlpatterns_reverse/tests.py
+++ b/tests/urlpatterns_reverse/tests.py
@@ -1141,10 +1141,30 @@ def test_repr(self):
self.assertEqual(
repr(resolve('/no_kwargs/42/37/')),
"ResolverMatch(func... | ResolverMatch.__repr__() doesn't handle functools.partial() nicely.
Description
(last modified by Nick Pope)
When a partial function is passed as the view, the __repr__ shows the func argument as functools.partial which isn't very helpful, especially as it doesn't reveal the underlying function or arguments pro... | ["test_repr (urlpatterns_reverse.tests.ResolverMatchTests)", "test_repr_functools_partial (urlpatterns_reverse.tests.ResolverMatchTests)", "test_resolver_match_on_request (urlpatterns_reverse.tests.ResolverMatchTests)"] | ["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... | 2021-03-19 15:44:25 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py | |
django__django-14311 | django/django | 5a8e8f80bb82a867eab7e4d9d099f21d0a976d22 | 4.0 | diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -223,8 +223,13 @@ def get_child_arguments():
# __spec__ is set when the server was started with the `-m` option,
# see https://docs.python.org/3/reference/import.html#main-... | diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -23,7 +23,7 @@
from django.utils import autoreload
from django.utils.autoreload import WatchmanUnavailable
-from .test_module import __mai... | Allow autoreloading of `python -m custom_module runserver`
Description
(last modified by Mariusz Felisiak)
The original fix [1] only attempted to deal with -m foo.bar where bar is a package and __main__.py exists under foo/bar.
When a dotted name for a module (for example, foo.bar.baz where baz.py resides under... | Patch
It doesn't work in Django 3.1 so I would not call it a regression. Can you send PR via GitHub?
Looks fine. The one change I'd make is that I'd change modspec.name.split(".")[-1] == "__main__" to modspec.name == "__main__" or modspec.name.endswith(".__main__") to avoid dumb corner cases like a module named foo.my_... | ["test_run_as_non_django_module_non_package (utils_tests.test_autoreload.TestChildArguments)"] | ["test_is_django_module (utils_tests.test_autoreload.TestUtilities)", "test_is_django_path (utils_tests.test_autoreload.TestUtilities)", "test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests... | 2021-04-25 02:54:34 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14349 | django/django | a708f39ce67af174df90c5b5e50ad1976cec7cb8 | 4.0 | diff --git a/django/core/validators.py b/django/core/validators.py
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -92,6 +92,7 @@ class URLValidator(RegexValidator):
r'\Z', re.IGNORECASE)
message = _('Enter a valid URL.')
schemes = ['http', 'https', 'ftp', 'ftps']
+ unsafe_chars... | diff --git a/tests/validators/tests.py b/tests/validators/tests.py
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -226,9 +226,15 @@
(URLValidator(), None, ValidationError),
(URLValidator(), 56, ValidationError),
(URLValidator(), 'no_scheme', ValidationError),
- # Trailing newlines ... | URLValidator tests failing on Python versions patched for bpo-43882
Description
On Python versions with a fix for bpo-43882 (i.e. 3.10.0b1 and the 3.9 git branch, not released yet) the following tests fail:
======================================================================
FAIL: test_validators (validators.tests... | Thanks for the report. We noticed this issue.
Duplicate of #32074.
For the record, I was wrong that this hasn't been released in 3.9 -- it's part of 3.9.5.
It looks that it will be backported to all supported versions of Python. | ["test_validators (validators.tests.TestValidators)"] | ["test_domain_whitelist (validators.tests.DeprecationTests)", "test_domain_whitelist_access_warning (validators.tests.DeprecationTests)", "test_domain_whitelist_set_warning (validators.tests.DeprecationTests)", "test_whitelist (validators.tests.DeprecationTests)", "test_whitelist_warning (validators.tests.DeprecationTe... | 2021-05-04 20:10:27 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14373 | django/django | b1a4b1f0bdf05adbd3dc4dde14228e68da54c1a3 | 4.0 | diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -313,8 +313,8 @@ def y(self):
return '%02d' % (self.data.year % 100)
def Y(self):
- "Year, 4 digits; e.g. '1999'"
- return self.data.year
+ """Ye... | diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py
--- a/tests/utils_tests/test_dateformat.py
+++ b/tests/utils_tests/test_dateformat.py
@@ -166,7 +166,7 @@ def test_r_format_with_non_en_locale(self):
'Sun, 08 Jul 1979 22:00:00 +0100',
)
- def tes... | DateFormat.Y() is not zero-padded.
Description
The Y specifier for django.utils.dateformat.DateFormat is supposed to always return a four-digit year padded with zeros. This doesn't seem to be the case for year < 1000.
| ["test_Y_format_year_before_1000 (utils_tests.test_dateformat.DateFormatTests)"] | ["test_am_pm (utils_tests.test_dateformat.DateFormatTests)", "test_date (utils_tests.test_dateformat.DateFormatTests)", "test_date_formats (utils_tests.test_dateformat.DateFormatTests)", "test_dateformat (utils_tests.test_dateformat.DateFormatTests)", "test_datetime_with_local_tzinfo (utils_tests.test_dateformat.DateFo... | 2021-05-10 14:40:32 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py | |
django__django-14376 | django/django | d06c5b358149c02a62da8a5469264d05f29ac659 | 4.0 | diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -200,9 +200,9 @@ def get_connection_params(self):
if settings_dict['USER']:
kwargs['user'] = settings_dict['USER']
if settings_... | diff --git a/tests/dbshell/test_mysql.py b/tests/dbshell/test_mysql.py
--- a/tests/dbshell/test_mysql.py
+++ b/tests/dbshell/test_mysql.py
@@ -50,41 +50,49 @@ def test_options_override_settings_proper_values(self):
'optiondbname',
]
expected_env = {'MYSQL_PWD': 'optionpassword'}
- ... | MySQL backend uses deprecated "db" and "passwd" kwargs.
Description
The "db" and "passwd" usage can be seen at https://github.com/django/django/blob/ca9872905559026af82000e46cde6f7dedc897b6/django/db/backends/mysql/base.py#L202-L205 in main. mysqlclient recently marked these two kwargs as deprecated (see https://gi... | Thanks for this report. Django 2.2, 3.1, and 3.2 all require a minimum version of mysqlclient newer than 1.3.8, so a fix for this could be backported to all currently supported versions of Django. Django 2.2 and 3.1 are in extended support so they don't receive bugfixes anymore (except security patches). We'll document... | ["test_options_non_deprecated_keys_preferred (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_options_override_settings_proper_values (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_parameters (dbshell.test_mysql.MySqlDbshellCommandTestCase)"] | ["test_basic_params_specified_in_settings (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_can_connect_using_sockets (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_crash_password_does_not_leak (dbshell.test_mysql.MySqlDbshellCommandTestCase)", "test_fails_with_keyerror_on_incomplete_config (dbshell.te... | 2021-05-10 20:42:18 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14493 | django/django | 7272e1963ffdf39c1d4fe225d5425a45dd095d11 | 4.0 | diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -260,6 +260,7 @@ def post_process(self, paths, dry_run=False, **options):
processed_adjustable_paths[name] = (name, hashe... | diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py
--- a/tests/staticfiles_tests/storage.py
+++ b/tests/staticfiles_tests/storage.py
@@ -97,3 +97,7 @@ class ExtraPatternsStorage(ManifestStaticFilesStorage):
class NoneHashStorage(ManifestStaticFilesStorage):
def file_hash(self, na... | ManifestStaticFilesStorage crashes with max_post_process_passes = 0.
Description
To reproduce:
Derive a custom class from ManifestStaticFilesStorage and set max_post_process_passes to 0:
class MyManifestStaticFilesStorage(ManifestStaticFilesStorage):
max_post_process_passes = 0
# settings.py
STATICFILES_STORAGE = "M... | An effective workaround is overriding patterns = (). It might not be worth fixing the UnboundLocalError.
I think it's worth fixing.
Hi guys, Can I work on this?
Replying to kingliar420: Can I work on this? Sure there is no need to ask. Please remember that a regression test is required. | ["test_collectstatistic_no_post_process_replaced_paths (staticfiles_tests.test_storage.TestCollectionNoPostProcessReplacedPaths)"] | ["test_hashed_name (staticfiles_tests.test_storage.TestCollectionNoneHashStorage)", "With storage classes having several file extension patterns, only the", "test_collect_static_files_default_permissions (staticfiles_tests.test_storage.TestStaticFilePermissions)", "test_collect_static_files_permissions (staticfiles_tes... | 2021-06-05 12:50:25 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14534 | django/django | 910ecd1b8df7678f45c3d507dde6bcb1faafa243 | 4.0 | diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -277,7 +277,7 @@ def template_name(self):
@property
def id_for_label(self):
- return 'id_%s_%s' % (self.data['name'], self.data['index'])
+ return self.data... | diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -720,7 +720,7 @@ class BeatleForm(Form):
fields = list(BeatleForm(auto_id=False)['name'])
self.assertEqual(len(fields), ... | BoundWidget.id_for_label ignores id set by ChoiceWidget.options
Description
If you look at the implementation of BoundField.subwidgets
class BoundField:
...
def subwidgets(self):
id_ = self.field.widget.attrs.get('id') or self.auto_id
attrs = {'id': id_} if id_ else {}
attrs = self.build_widget_attrs(attrs)
... | Hey Jacob — Sounds right: I didn't look in-depth but, if you can put your example in a test case it will be clear enough in the PR. Thanks.
Thanks Carlton, I will create a pull request asap.
Here is a pull request fixing this bug: https://github.com/django/django/pull/14533 (closed without merging)
Here is the new pul... | ["If auto_id is provided when initializing the form, the generated ID in", "test_iterable_boundfield_select (forms_tests.tests.test_forms.FormsTestCase)"] | ["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for... | 2021-06-17 15:37:34 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14539 | django/django | 6a5ef557f80a8eb6a758ebe99c8bb477ca47459e | 4.0 | diff --git a/django/utils/html.py b/django/utils/html.py
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -283,8 +283,9 @@ def trim_punctuation(lead, middle, trail):
middle_unescaped = html.unescape(middle)
stripped = middle_unescaped.rstrip(TRAILING_PUNCTUATION_CHARS)
if ... | diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -250,6 +250,10 @@ def test_urlize(self):
'Search for google.com/?q=! and see.',
'Search for <a href="http://google.com/?q=">google.c... | urlize() does not handle html escaped string and trailing punctuation correctly
Description
Example:
urlize('Search for google.com/?q=1<! and see.')
# expected output
'Search for <a href="http://google.com/?q=1%3C">google.com/?q=1<</a>! and see.'
# actual output
'Search for <a href="http://google.com/?q=1%3C">goo... | https://github.com/django/django/pull/14539/
OK, thanks, the example looks right. It's always delicate but let's take this for review. Related to #26193. | ["test_urlize (utils_tests.test_html.TestUtilsHtml)", "test_urlize_unchanged_inputs (utils_tests.test_html.TestUtilsHtml)"] | ["test_conditional_escape (utils_tests.test_html.TestUtilsHtml)", "test_escape (utils_tests.test_html.TestUtilsHtml)", "test_escapejs (utils_tests.test_html.TestUtilsHtml)", "test_format_html (utils_tests.test_html.TestUtilsHtml)", "test_html_safe (utils_tests.test_html.TestUtilsHtml)", "test_html_safe_defines_html_err... | 2021-06-19 11:31:16 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14559 | django/django | d79be3ed39b76d3e34431873eec16f6dd354ab17 | 4.0 | diff --git a/django/db/models/query.py b/django/db/models/query.py
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -541,7 +541,7 @@ def bulk_update(self, objs, fields, batch_size=None):
if any(f.primary_key for f in fields):
raise ValueError('bulk_update() cannot be used with pr... | diff --git a/tests/queries/test_bulk_update.py b/tests/queries/test_bulk_update.py
--- a/tests/queries/test_bulk_update.py
+++ b/tests/queries/test_bulk_update.py
@@ -125,7 +125,8 @@ def test_update_custom_primary_key(self):
def test_empty_objects(self):
with self.assertNumQueries(0):
- Note.... | Include number of rows matched in bulk_update() return value
Description
Currently, bulk_update() returns None, unlike update(), which returns the number of rows matched.
It looks like it would be easy to add the same functionality to bulk_update() since bulk_update() simply calls update() repeatedly:
https://githu... | Also, if this feature is okayed, maybe the number could be returned in a way that would permit other useful numbers to be added to the return value in a backwards-compatible way later on. For example, the number could be returned as a property of a named tuple with one property. That way, if a new value is requested in... | ["test_empty_objects (queries.test_bulk_update.BulkUpdateTests)", "test_large_batch (queries.test_bulk_update.BulkUpdateTests)", "test_updated_rows_when_passing_duplicates (queries.test_bulk_update.BulkUpdateTests)"] | ["test_batch_size (queries.test_bulk_update.BulkUpdateNoteTests)", "test_foreign_keys_do_not_lookup (queries.test_bulk_update.BulkUpdateNoteTests)", "test_functions (queries.test_bulk_update.BulkUpdateNoteTests)", "test_multiple_fields (queries.test_bulk_update.BulkUpdateNoteTests)", "test_set_field_to_null (queries.te... | 2021-06-26 05:38:46 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14608 | django/django | 7f33c1e22dbc34a7afae7967783725b10f1f13b1 | 4.0 | diff --git a/django/forms/formsets.py b/django/forms/formsets.py
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -333,7 +333,7 @@ def full_clean(self):
self._non_form_errors.
"""
self._errors = []
- self._non_form_errors = self.error_class()
+ self._non_form_err... | diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -3348,7 +3348,10 @@ def test_non_form_errors_is_errorlist(self):
response = self.client.post(reverse('admin:admin_views_person_changelist'), data)
non_form_errors =... | Add `nonform` CSS class for non form errors in FormSets
Description
(last modified by Ties Jan Hefting)
Forms add the nonfield CSS class for non field errors in ErrorList instances. This is documented in a section on rendering form error messages. Similarly, in FormSets I'd expect to see the nonform CSS class ... | Seems reasonable (similar to #11776).
PR | ["If validate_max is set and max_num is less than TOTAL_FORMS in the", "If validate_min is set and min_num is more than TOTAL_FORMS in the", "test_non_form_errors (forms_tests.tests.test_formsets.FormsFormsetTestCase)", "test_non_form_errors_is_errorlist (admin_views.tests.AdminViewListEditable)"] | ["all_valid() validates all forms, even when some are invalid.", "test_valid (forms_tests.tests.test_formsets.AllValidTests)", "is_multipart() works with an empty formset.", "An empty formset still calls clean()", "Media is available on empty formset.", "test_customize_management_form_error (forms_tests.tests.test_form... | 2021-07-07 19:51:30 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14631 | django/django | 84400d2e9db7c51fee4e9bb04c028f665b8e7624 | 4.0 | diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -1,6 +1,7 @@
import datetime
import re
+from django.core.exceptions import ValidationError
from django.forms.utils import flatatt, pretty_name
from django.forms.widgets import ... | diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -2112,15 +2112,47 @@ class DateTimeForm(Form):
self.assertEqual(unbound['hi_without_microsec'].value(), now_no_ms)
self.... | BaseForm's _clean_fields() and changed_data should access values via BoundField
Description
(last modified by Chris Jerdonek)
While working on #32917, I noticed that BaseForm._clean_fields() and BaseForm.changed_data don't currently access their values through a BoundField object. It would be better for consi... | Here is how to make the failing test I mentioned above (roughly): def test_datetime_clean_initial_callable_disabled(self): - now = datetime.datetime(2006, 10, 25, 14, 30, 45, 123456) - class DateTimeForm(forms.Form): - dt = DateTimeField(initial=lambda: now, disabled=True) + dt = DateTimeField(initial=datetime.datetime... | ["The cleaned value for a form with a disabled DateTimeField and callable", "Cleaning a form with a disabled DateTimeField and callable initial"] | ["test_attribute_class (forms_tests.tests.test_forms.RendererTests)", "test_attribute_instance (forms_tests.tests.test_forms.RendererTests)", "test_attribute_override (forms_tests.tests.test_forms.RendererTests)", "test_default (forms_tests.tests.test_forms.RendererTests)", "test_kwarg_class (forms_tests.tests.test_for... | 2021-07-13 09:16:48 | 1-4 hours | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14672 | django/django | 00ea883ef56fb5e092cbe4a6f7ff2e7470886ac4 | 4.0 | diff --git a/django/db/models/fields/reverse_related.py b/django/db/models/fields/reverse_related.py
--- a/django/db/models/fields/reverse_related.py
+++ b/django/db/models/fields/reverse_related.py
@@ -310,7 +310,7 @@ def __init__(self, field, to, related_name=None, related_query_name=None,
def identity(self):
... | diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -821,6 +821,33 @@ class Child(Parent):
)
])
+ def test_field_name_clash_with_m2m_through(self):... | Missing call `make_hashable` on `through_fields` in `ManyToManyRel`
Description
In 3.2 identity property has been added to all ForeignObjectRel to make it possible to compare them. A hash is derived from said identity and it's possible because identity is a tuple. To make limit_choices_to hashable (one of this tuple ... | ["test_multiple_autofields (invalid_models_tests.test_models.MultipleAutoFieldsTests)", "test_db_column_clash (invalid_models_tests.test_models.FieldNamesTests)", "test_ending_with_underscore (invalid_models_tests.test_models.FieldNamesTests)", "test_including_separator (invalid_models_tests.test_models.FieldNamesTests... | [] | 2021-07-20 10:47:34 | 15 min - 1 hour | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py | |
django__django-14725 | django/django | 0af9a5fc7d765aa05ea784e2c3237675f3bb4b49 | 4.1 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -676,7 +676,10 @@ def save_m2m():
for form in self.saved_forms:
form.save_m2m()
self.save_m2m = save_m2m
- return self.save_existing_objects... | diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py
--- a/tests/model_formsets/tests.py
+++ b/tests/model_formsets/tests.py
@@ -1771,6 +1771,73 @@ def test_initial_form_count_empty_data(self):
formset = AuthorFormSet({})
self.assertEqual(formset.initial_form_count(), 0)
+ d... | Provide a way for model formsets to disallow new object creation
Description
Model formsets don't provide a way to create an "edit only" view of objects. We see users trying to use extra=0 to accomplish this, but that's not reliable as extra is merely meant for the extra number of forms to display. You can add more f... | In 8e6a08e: Refs #26142 -- Documented that Formset's extra=0 doesn't prevent creating objects.
In 204d31c: [1.9.x] Refs #26142 -- Documented that Formset's extra=0 doesn't prevent creating objects. Backport of 8e6a08e937272f088902cdbec65a9f2e919783bf from master
Doesn't max_num already allow this? Testing on master, if... | ["test_edit_only (model_formsets.tests.ModelFormsetTest)", "test_edit_only_inlineformset_factory (model_formsets.tests.ModelFormsetTest)", "test_edit_only_object_outside_of_queryset (model_formsets.tests.ModelFormsetTest)"] | ["Make sure that an add form that is filled out, but marked for deletion", "Make sure that a change form that is filled out, but marked for deletion", "test_deletion (model_formsets.tests.DeletionTests)", "test_outdated_deletion (model_formsets.tests.DeletionTests)", "test_callable_defaults (model_formsets.tests.ModelF... | 2021-08-01 21:24:36 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-14752 | django/django | b64db05b9cedd96905d637a2d824cbbf428e40e7 | 4.0 | diff --git a/django/contrib/admin/views/autocomplete.py b/django/contrib/admin/views/autocomplete.py
--- a/django/contrib/admin/views/autocomplete.py
+++ b/django/contrib/admin/views/autocomplete.py
@@ -11,7 +11,8 @@ class AutocompleteJsonView(BaseListView):
def get(self, request, *args, **kwargs):
"""
... | diff --git a/tests/admin_views/test_autocomplete_view.py b/tests/admin_views/test_autocomplete_view.py
--- a/tests/admin_views/test_autocomplete_view.py
+++ b/tests/admin_views/test_autocomplete_view.py
@@ -1,3 +1,4 @@
+import datetime
import json
from contextlib import contextmanager
@@ -293,6 +294,29 @@ class PKO... | Refactor AutocompleteJsonView to support extra fields in autocomplete response
Description
(last modified by mrts)
Adding data attributes to items in ordinary non-autocomplete foreign key fields that use forms.widgets.Select-based widgets is relatively easy. This enables powerful and dynamic admin site customiz... | Makes sense to me. | ["test_serialize_result (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)"] | ["test_custom_to_field (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_custom_to_field_custom_pk (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_custom_to_field_permission_denied (admin_views.test_autocomplete_view.AutocompleteJsonViewTests)", "test_field_does_not_allowed (... | 2021-08-07 16:34:32 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14771 | django/django | 4884a87e022056eda10534c13d74e49b8cdda632 | 4.1 | diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -220,6 +220,11 @@ def get_child_arguments():
py_script = Path(sys.argv[0])
args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions]
+ if sys.implementation.name... | diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -170,6 +170,7 @@ class TestChildArguments(SimpleTestCase):
@mock.patch.dict(sys.modules, {'__main__': django.__main__})
@mock.patch(... | Auto-reloader should pass -X options (for cpython implementation)
Description
Windows OS
$ winpty python -m django startproject my_project
$ cd my_project/
$ winpty python -m django startapp my_app
$ vi my_app/apps.py # demo for xoptions ...
$ cat -n my_app/apps.py
1 from django.apps import AppConfig
2
3 class ... | ["test_xoptions (utils_tests.test_autoreload.TestChildArguments)"] | ["test_common_roots (utils_tests.test_autoreload.TestCommonRoots)", "test_no_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_custom_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_exception (utils_tests.test_autoreload.TestRaiseLastException)", "test_raises_ex... | 2021-08-15 07:26:17 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py | |
django__django-14792 | django/django | d89f976bddb49fb168334960acc8979c3de991fa | 4.0 | diff --git a/django/utils/timezone.py b/django/utils/timezone.py
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -72,8 +72,11 @@ def get_current_timezone_name():
def _get_timezone_name(timezone):
- """Return the name of ``timezone``."""
- return str(timezone)
+ """
+ Return the offset ... | diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py
--- a/tests/utils_tests/test_timezone.py
+++ b/tests/utils_tests/test_timezone.py
@@ -260,6 +260,31 @@ def test_make_aware_zoneinfo_non_existent(self):
self.assertEqual(std.utcoffset(), datetime.timedelta(hours=1))
se... | Reverse time zone conversion in Trunc()/Extract() database functions.
Description
When using a time zone of "Etc/GMT-10" (or similar) for a Trunc class tzinfo, it appears there's a different behavior as of Django 3.2 in the resulting database query. I think it's due to a change in the return value of timezone._get_ti... | Thanks for the report. Regression in 10d126198434810529e0220b0c6896ed64ca0e88. Reproduced at 4fe3774c729f3fd5105b3001fe69a70bdca95ac3.
This problem is also affecting MySQL, the timezone "Etc/GMT-10" is returning "-10" instead of "-10:00". #33037 | ["The _get_timezone_name() helper must return the offset for fixed offset", "test_is_aware (utils_tests.test_timezone.TimezoneTests)"] | ["test_activate_invalid_timezone (utils_tests.test_timezone.TimezoneTests)", "test_fixedoffset_negative_timedelta (utils_tests.test_timezone.TimezoneTests)", "test_fixedoffset_timedelta (utils_tests.test_timezone.TimezoneTests)", "test_get_default_timezone (utils_tests.test_timezone.TimezoneTests)", "test_get_default_t... | 2021-08-24 09:25:15 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14855 | django/django | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | 4.0 | diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
--- a/django/contrib/admin/helpers.py
+++ b/django/contrib/admin/helpers.py
@@ -209,7 +209,11 @@ def get_admin_url(self, remote_field, remote_obj):
remote_field.model._meta.model_name,
)
try:
- url =... | diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -1142,6 +1142,8 @@ def get_formsets_with_inlines(self, request, obj=None):
raw_id_fields=['parent'],
)
site2.register(Person, save_as_continue=False)
+site2.register(ReadOnlyR... | Wrong URL generated by get_admin_url for readonly field in custom Admin Site
Description
When a model containing a ForeignKey field is viewed (or edited) in a custom Admin Site, and that ForeignKey field is listed in readonly_fields, the url generated for the link is /admin/... instead of /custom-admin/....
This appe... | Hey Ken, yes seems right. Good spot. Looks like this should have been part of b79088306513d5ed76d31ac40ab3c15f858946ea for #31181 (which was Django 3.2) here. However, I don't know if there are any side effects and I have not yet run the full suite of tests on this. Mostly looking for feedback whether I'm on the right... | ["test_readonly_foreignkey_links_custom_admin_site (admin_views.tests.ReadonlyTest)"] | ["test_explicitly_provided_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_implicitly_generated_pk (admin_views.tests.GetFormsetsWithInlinesArgumentTest)", "test_should_be_able_to_edit_related_objects_on_add_view (admin_views.tests.AdminCustomSaveRelatedTests)", "test_should_be_able_to_edit_related_ob... | 2021-09-14 01:27:01 | <15 min fix | 475cffd1d64c690cdad16ede4d5e81985738ceb4 | null | null | null | null | null | swebench_verified | py |
django__django-14999 | django/django | a754b82dac511475b6276039471ccd17cc64aeb8 | 4.1 | diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -320,12 +320,13 @@ def database_forwards(self, app_label, schema_editor, from_state, to_state):
new_model = to_st... | diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -793,6 +793,28 @@ def test_rename_model_with_m2m(self):
self.assertEqual(Rider.objects.count(), 2)
self.assertEqual(Pony._meta.g... | RenameModel with db_table should be a noop.
Description
A RenameModel operation that already has db_table defined must be a noop.
In Postgres, it drops and recreates foreign key constraints. In sqlite it recreates the table (as expected for a table renaming).
| ["test_rename_model_with_db_table_noop (migrations.test_operations.OperationTests)"] | ["test_references_model_mixin (migrations.test_operations.TestCreateModel)", "test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.Fiel... | 2021-10-16 09:31:21 | <15 min fix | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py | |
django__django-15022 | django/django | e1d673c373a7d032060872b690a92fc95496612e | 4.1 | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1031,6 +1031,7 @@ def construct_search(field_name):
if search_fields and search_term:
orm_lookups = [construct_search(str(search_field))
... | diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py
--- a/tests/admin_changelist/admin.py
+++ b/tests/admin_changelist/admin.py
@@ -36,6 +36,12 @@ class ParentAdmin(admin.ModelAdmin):
list_select_related = ['child']
+class ParentAdminTwoSearchFields(admin.ModelAdmin):
+ list_filte... | Unnecessary joins in admin changelist query
Description
Django 1.2.5
Models:
class Client(models.Model):
name = models.CharField(_('name'), max_length=256)
name2 = models.CharField(_('unofficial or obsolete name'), max_length=256, blank=True, null=True)
contact_person = models.CharField(_('contact person'), max_le... | patch has been made from Mercurial repository
This seems related to #13902 and #15819. Are you able to test if this gets fixed by using Django 1.3 or trunk?
Looking at the code, the part that is modified by the patch is not modified in current trunk. The problematic pattern is still there: for bit in self.query.split()... | ["test_many_search_terms (admin_changelist.tests.ChangeListTests)", "All rows containing each of the searched words are returned, where each", "Searches over multi-valued relationships return rows from related"] | ["{% get_admin_log %} works if the user model's primary key isn't named", "test_missing_args (admin_changelist.tests.GetAdminLogTests)", "{% get_admin_log %} works without specifying a user.", "test_non_integer_limit (admin_changelist.tests.GetAdminLogTests)", "test_without_as (admin_changelist.tests.GetAdminLogTests)"... | 2021-10-24 17:48:28 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15037 | django/django | dab48b7482295956973879d15bfd4d3bb0718772 | 4.1 | diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
--- a/django/core/management/commands/inspectdb.py
+++ b/django/core/management/commands/inspectdb.py
@@ -116,13 +116,17 @@ def table2model(table_name):
extra_params['unique'] = True
... | diff --git a/tests/inspectdb/models.py b/tests/inspectdb/models.py
--- a/tests/inspectdb/models.py
+++ b/tests/inspectdb/models.py
@@ -21,6 +21,12 @@ class PeopleMoreData(models.Model):
license = models.CharField(max_length=255)
+class ForeignKeyToField(models.Model):
+ to_field_fk = models.ForeignKey(
+ ... | Foreign key to a specific field is not handled in inspectdb
Description
(last modified by Tim Graham)
if you have a DB like that
CREATE TABLE foo ( id serial primary key, other_id int UNIQUE);
CREATE TABLE bar (
id serial primary key, other_id int,
constraint myconst
FOREIGN KEY(other_id) references foo(oth... | simple patch to handle FK to non pk field.
it seems I cannot reproduce outside of my own code...
I will check it! | ["test_foreign_key_to_field (inspectdb.tests.InspectDBTestCase)"] | ["inspectdb --include-views creates models for database views.", "test_attribute_name_not_python_keyword (inspectdb.tests.InspectDBTestCase)", "test_char_field_db_collation (inspectdb.tests.InspectDBTestCase)", "Introspection of column names consist/start with digits (#16536/#17676)", "Test introspection of various Dja... | 2021-10-30 15:21:38 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15098 | django/django | 2c7846d992ca512d36a73f518205015c88ed088c | 4.1 | diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -43,7 +43,7 @@
re.IGNORECASE
)
-language_code_prefix_re = _lazy_re_compile(r'^/(\w+([@-]\w+)?)(/|$)')
+language_code_prefix_re... | diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1593,22 +1593,41 @@ def test_get_supported_language_variant_null(self):
@override_settings(
LANGUAGES=[
('en', 'English'),
+ ('en-latn-us', 'Latin English'),
+ ... | Internationalisation didn't support language locale containing both script and region.
Description
The i18n_patterns didn't work with locale contains both script and region, like en-latn-us.
Given settings.py
LANGUAGE_CODE = 'en-us'
LANGUAGES = [
('en-us', "English"),
('en-latn-us', "Latin English"),
('en-Latn-US'... | What's the use case of using en-latn-us?
Replying to Claude Paroz: What's the use case of using en-latn-us? Our language, Taigi in Taiwan, is denoted by nan in ISO 639-3. nan denoted other languages which are different from Taigi although we are submitting the proposal for new language code this year. So that the langu... | ["test_get_language_from_path_real (i18n.tests.MiscTests)", "test_get_supported_language_variant_null (i18n.tests.MiscTests)"] | ["OSError is raised if the default language is unparseable.", "test_ignores_non_mo_files (i18n.tests.TranslationFileChangedTests)", "test_resets_cache_with_mo_files (i18n.tests.TranslationFileChangedTests)", "test_round_away_from_one (i18n.tests.UtilsTests)", "test_lazy (i18n.tests.TestModels)", "test_safestr (i18n.tes... | 2021-11-17 21:30:07 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15103 | django/django | dd528cb2cefc0db8b91a7ff0a2bc87305b976597 | 4.1 | diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -83,10 +83,10 @@ def escapejs_filter(value):
@register.filter(is_safe=True)
-def json_script(value, element_id):
+def json_script(value, element_id=N... | diff --git a/tests/template_tests/filter_tests/test_json_script.py b/tests/template_tests/filter_tests/test_json_script.py
--- a/tests/template_tests/filter_tests/test_json_script.py
+++ b/tests/template_tests/filter_tests/test_json_script.py
@@ -17,3 +17,8 @@ def test_basic(self):
'{"a": "testing\\r\\njso... | Make the element_id argument of json_script optional
Description
I recently had a use-case where I wanted to use json_script but I didn't need any id for it (I was including the <script> inside a <template> so I didn't need an id to refer to it).
I can't see any reason (security or otherwise) for the id to be require... | ["test_without_id (template_tests.filter_tests.test_json_script.JsonScriptTests)", "test_json_script_without_id (utils_tests.test_html.TestUtilsHtml)"] | ["test_basic (template_tests.filter_tests.test_json_script.JsonScriptTests)", "test_conditional_escape (utils_tests.test_html.TestUtilsHtml)", "test_escape (utils_tests.test_html.TestUtilsHtml)", "test_escapejs (utils_tests.test_html.TestUtilsHtml)", "test_format_html (utils_tests.test_html.TestUtilsHtml)", "test_html_... | 2021-11-19 15:57:54 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py | |
django__django-15104 | django/django | a7e7043c8746933dafce652507d3b821801cdc7d | 4.1 | diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -96,7 +96,7 @@ def only_relation_agnostic_fields(self, fields):
for name, field in sorted(fields.items()):
deconstructio... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -2834,6 +2834,28 @@ def test_parse_number(self):
expected_number,
)
+ def test_add_custom_fk_wi... | KeyError with migration autodetector and FK field with hardcoded reference
Description
Hi,
I encountered this issue on an old Django project (probably 10 years old) with tons of models and probably a lot of questionable design decisions.
The symptom is that running our test suite in verbose mode doesn't work:
$ pytho... | ["test_add_custom_fk_with_hardcoded_to (migrations.test_autodetector.AutodetectorTests)"] | ["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest... | 2021-11-19 20:46:58 | <15 min fix | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py | |
django__django-15128 | django/django | cb383753c0e0eb52306e1024d32a782549c27e61 | 4.1 | diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -572,6 +572,15 @@ def combine(self, rhs, connector):
if self.distinct_fields != rhs.distinct_fields:
raise TypeError('Cannot combine queries with di... | diff --git a/tests/queries/models.py b/tests/queries/models.py
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -613,13 +613,14 @@ def __str__(self):
class BaseUser(models.Model):
- pass
+ annotation = models.ForeignKey(Annotation, models.CASCADE, null=True, blank=True)
class Task(models.M... | Query.change_aliases raises an AssertionError
Description
Python Version: 3.9.2
Django Version: 2.2.24, 3.2.9 (reproduced using two different versions)
Code to Reproduce
# models.py
from django.db import models
class Foo(models.Model):
qux = models.ForeignKey("app.Qux", on_delete=models.CASCADE, related_name="foos"... | Thanks for the report. Reproduced at b8c0b22f2f0f8ce664642332d6d872f300c662b4.
Vishal Pandey, if you're looking for pointers on how to resolve the issue I think I have a pretty good understanding of the problem. The root cause is that both queries happen to share the same alias_prefix; the letter used generate aliases ... | ["test_conflicting_aliases_during_combine (queries.tests.QuerySetBitwiseOperationTests)"] | ["test_ticket14729 (queries.tests.RawQueriesTests)", "test_datetimes_invalid_field (queries.tests.Queries3Tests)", "test_ticket22023 (queries.tests.Queries3Tests)", "test_ticket7107 (queries.tests.Queries3Tests)", "test_21001 (queries.tests.EmptyStringsAsNullTest)", "test_direct_exclude (queries.tests.EmptyStringsAsNul... | 2021-11-25 15:50:24 | 1-4 hours | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15161 | django/django | 96e7ff5e9ff6362d9a886545869ce4496ca4b0fb | 4.1 | diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -651,6 +651,7 @@ def relabeled_clone(self, relabels):
return self
+@deconstructible(path='django.db.models.Func')
class Func(SQLiteNumericMixin, Exp... | diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -1763,14 +1763,14 @@ def test_update_UUIDField_using_Value(self):
def test_deconstruct(self):
value = Value('name')
path, args, kwargs = value.deconstruct()
- ... | Use simplified paths for deconstruct of expressions
Description
Previously F() deconstructed to: django.db.models.expressions.F(). But since it can also be imported from django.db.models, PR #14047 changed it to deconstruct to django.db.models.F(). This simplifies generated migration code where it will be referenced... | I would like to give this a try if someone can guide me on how to proceed with this problem.
I don't think much more guidance can be given particular to this ticket. Did you see the example PR? Have you read the contributing guidelines and the first patch tutorial? | ["test_deconstruct (expressions.tests.ValueTests)", "test_deconstruct_output_field (expressions.tests.ValueTests)", "test_serialize_complex_func_index (migrations.test_writer.WriterTests)"] | ["test_equal (expressions.tests.OrderByTests)", "test_hash (expressions.tests.OrderByTests)", "test_and (expressions.tests.CombinableTests)", "test_negation (expressions.tests.CombinableTests)", "test_or (expressions.tests.CombinableTests)", "test_reversed_and (expressions.tests.CombinableTests)", "test_reversed_or (ex... | 2021-12-06 09:06:13 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15252 | django/django | 361bb8f786f112ee275be136795c0b1ecefff928 | 4.1 | diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -96,8 +96,12 @@ def migrate(self, targets, plan=None, state=None, fake=False, fake_initial=False
(un)applied and in a second step run all the databas... | diff --git a/tests/backends/base/test_creation.py b/tests/backends/base/test_creation.py
--- a/tests/backends/base/test_creation.py
+++ b/tests/backends/base/test_creation.py
@@ -57,12 +57,12 @@ def test_custom_test_name_with_test_prefix(self):
@mock.patch.object(connection, 'ensure_connection')
@mock.patch.object(co... | MigrationRecorder does not obey db_router allow_migrate rules
Description
Hi,
We have a multi-db setup. We have one connection that is for the django project, and several connections that talk to other dbs for information (ie models with managed = False). Django should only create tables in the first connection, neve... | I don't think you've implemented your router correctly, but I'd need to check the router code to see if it's called multiple times (num_dbs*num_models) to be sure. This is how we implement our routers for allow_migrate: def allow_migrate(self, db, model): if db == 'other': return model._meta.app_label == 'legacy_app' #... | ["test_migrate_test_setting_false_ensure_schema (backends.base.test_creation.TestDbCreationTests)", "The django_migrations table is not created if there are no migrations"] | ["test_mark_expected_failures_and_skips (backends.base.test_creation.TestMarkTests)", "test_custom_test_name (backends.base.test_creation.TestDbSignatureTests)", "test_custom_test_name_with_test_prefix (backends.base.test_creation.TestDbSignatureTests)", "test_default_name (backends.base.test_creation.TestDbSignatureTe... | 2021-12-28 15:51:06 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15268 | django/django | 0ab58c120939093fea90822f376e1866fc714d1f | 4.1 | diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -34,9 +34,12 @@ def references_model(self, name, app_label):
def reduce(self, operation, app_label):
return ... | diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -1573,21 +1573,13 @@ def test_foo_together_ordering(self):
self.assertOperationTypes(changes, 'otherapp', 0, [
'Alte... | Optimize multiple AlterFooTogether operations into one
Description
Hi,
In #31503 we split the AlterFooTogether (AlterUniqueTogether and AlterIndexTogether) operations into two types of operations.
First, a migration will have operations to remove constraints, and then other operations adds the new constraints. This a... | ["index/unique_together also triggers on ordering changes.", "Removed fields will be removed after updating index/unique_together.", "Fields are renamed before updating index/unique_together."] | ["test_auto (migrations.test_autodetector.MigrationSuggestNameTests)", "test_many_operations_suffix (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations (migrations.test_autodetector.MigrationSuggestNameTests)", "test_no_operations_initial (migrations.test_autodetector.MigrationSuggestNameTest... | 2022-01-01 09:57:13 | 1-4 hours | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py | |
django__django-15375 | django/django | beb7ddbcee03270e833b2f74927ccfc8027aa693 | 4.1 | diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -65,7 +65,9 @@ def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize
if hasattr(default, 'resolve_expression'):
defau... | diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -1630,6 +1630,18 @@ def test_aggregation_default_passed_another_aggregate(self):
)
self.assertAlmostEqual(result['value'], Decimal('61.72'), places=2)
+ def te... | aggregate() with 'default' after annotate() crashes.
Description
I saw this on a PostgreSQL project and reproduced it with SQLite. Django 4.0.1.
Annotate (anything) then aggregate works fine:
$ ./manage.py shell
Python 3.10.2 (main, Jan 21 2022, 19:45:54) [Clang 13.0.0 (clang-1300.0.29.30)]
Type 'copyright', 'credits... | Thanks for the report! Would you like to prepare a patch? If not, you can assign it me as 4.0.2 will be issued on Tuesday.
I have had a quick look but I got a bit lost. Aggregate.default generates a Coalesce internally so it seems a little lower level. If you have the capacity that would be appreciated.
Replying to Ada... | ["test_aggregation_default_after_annotation (aggregation.tests.AggregateTestCase)"] | ["test_add_implementation (aggregation.tests.AggregateTestCase)", "test_aggregate_alias (aggregation.tests.AggregateTestCase)", "test_aggregate_annotation (aggregation.tests.AggregateTestCase)", "test_aggregate_in_order_by (aggregation.tests.AggregateTestCase)", "test_aggregate_join_transform (aggregation.tests.Aggrega... | 2022-01-28 14:48:03 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15467 | django/django | e0442a628eb480eac6a7888aed5a86f83499e299 | 4.1 | diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -269,7 +269,9 @@ def formfield_for_foreignkey(self, db_field, request, **kwargs):
"class": get_ul_class(self.radio_fields[db_field.name])... | diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -21,6 +21,7 @@
CharField,
DateField,
DateTimeField,
+ ForeignKey,
ManyToManyField,
UUIDField,
)
@@ -141,6 +142,17 @@ def test_radio_fields_Foreig... | ModelAdmin with defined radio_fields override empty_label
Description
ModelAdmin drops my "empty_label" and set "default_empty_label". For example:
class MyModelAdmin(ModelAdmin):
radio_fields = 'myfield',
def formfield_for_foreignkey(self, db_field, *args, **kwargs):
if db_field.name == 'myfield':
kwargs['emp... | Agreed, empty_label from kwargs should take precedence over _('None').
I want to work on this to get familiarised with contributing process. Assigning this to me. | ["test_radio_fields_foreignkey_formfield_overrides_empty_label (admin_widgets.tests.AdminFormfieldForDBFieldTests)"] | ["test_CharField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_DateField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_DateTimeField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_EmailField (admin_widgets.tests.AdminFormfieldForDBFieldTests)", "test_FileField (admin_widgets.tes... | 2022-02-27 03:00:31 | <15 min fix | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15525 | django/django | fbacaa58ffc5a62456ee68b90efa13957f761ce4 | 4.1 | diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py
--- a/django/core/serializers/base.py
+++ b/django/core/serializers/base.py
@@ -336,7 +336,9 @@ def build_instance(Model, data, db):
and hasattr(default_manager, "get_by_natural_key")
and hasattr(Model, "natural_key")
... | diff --git a/tests/backends/sqlite/test_features.py b/tests/backends/sqlite/test_features.py
--- a/tests/backends/sqlite/test_features.py
+++ b/tests/backends/sqlite/test_features.py
@@ -10,8 +10,9 @@ def test_supports_json_field_operational_error(self):
if hasattr(connection.features, "supports_json_field"):
... | loaddata fails on non-default database when natural keys uses foreign keys.
Description
(last modified by François Granade)
I've got a one-to-many relationship between two models Book and Author, that define a natural keys in both models. I'm loading some data from a fixture. It works in the default database, b... | Thanks for this report. I was able to fix the issue by specifying db before checking natural_key(): django/core/serializers/base.py diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index da85cb4b92..517d2cad85 100644 a b def build_instance(Model, data, db): 336336 and hasattr(default_manag... | ["Natural keys with foreing keys in dependencies works in a multiple"] | ["test_supports_json_field_operational_error (backends.sqlite.test_features.FeaturesTests)", "test_fixtures_loaded (fixtures_regress.tests.TestLoadFixtureFromOtherAppDirectory)", "M2M relations with explicit through models should NOT count as", "Circular M2M relations with explicit through models should be serializable... | 2022-03-18 10:39:26 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15561 | django/django | 6991880109e35c879b71b7d9d9c154baeec12b89 | 4.1 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -1376,22 +1376,9 @@ def _field_should_be_altered(self, old_field, new_field):
# - changing only a field name
# - changing an attribute t... | diff --git a/tests/schema/tests.py b/tests/schema/tests.py
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -3961,6 +3961,20 @@ def test_alter_field_fk_attributes_noop(self):
with connection.schema_editor() as editor, self.assertNumQueries(0):
editor.alter_field(Book, new_field, old_fiel... | AlterField operation should be noop when adding/changing choices on SQLite.
Description
while writing a test case for #33470 i found that for sqlite, even a seemingly db-transparent change like adding choices still generates sql (new table + insert + drop + rename) even though this shouldn't be needed. on e.g. postgr... | It was missed in #25253 (see 9159d173c3822312c653db7ff5b9a94b14af1dca). Adding choices to the non_database_attrs should fix it: django/db/backends/base/schema.py diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 4cd4567cbc..822da656d3 100644 a b class BaseDatabaseSchemaEditor: 113... | ["test_alter_field_choices_noop (schema.tests.SchemaTests)"] | ["effective_default() should be used for DateField, DateTimeField, and", "Tests adding fields to models", "Tests binary fields get a sane default (#22851)", "test_add_field_db_collation (schema.tests.SchemaTests)", "test_add_field_default_dropped (schema.tests.SchemaTests)", "test_add_field_default_nullable (schema.tes... | 2022-04-01 18:29:04 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15563 | django/django | 9ffd4eae2ce7a7100c98f681e2b6ab818df384a4 | 4.1 | diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1836,7 +1836,23 @@ def pre_sql_setup(self):
query.clear_ordering(force=True)
query.extra = {}
query.select = []
- query.add... | diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -667,3 +667,15 @@ def test_create_new_instance_with_pk_equals_none_multi_inheritance(self):
Politician.objects.ge... | Wrong behavior on queryset update when multiple inheritance
Description
Queryset update has a wrong behavior when queryset class inherits multiple classes. The update happens not on child class but on other parents class instances.
Here an easy example to show the problem:
class Base(models.Model):
base_id = models.... | Thank you for your report. Confirmed this is another issue with concrete MTI. I've looked at the code and in order to address the issue both sql.UpdateQuery and sql.SQLUpdateCompiler need to be updated. The changes revolve around changing UpdateQuery.related_ids: list[int] to related_ids: dict[Model, list[int]] and mak... | ["test_mti_update_grand_parent_through_child (model_inheritance_regress.tests.ModelInheritanceTest)", "test_mti_update_parent_through_child (model_inheritance_regress.tests.ModelInheritanceTest)"] | ["test_abstract_base_class_m2m_relation_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)", "test_abstract_base_class_m2m_relation_inheritance_manager_reused (model_inheritance_regress.tests.ModelInheritanceTest)", "verbose_name_plural correctly inherited from ABC if inheritance chain", "Regression tes... | 2022-04-06 02:48:01 | 15 min - 1 hour | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15572 | django/django | 0b31e024873681e187b574fe1c4afe5e48aeeecf | 4.1 | diff --git a/django/template/autoreload.py b/django/template/autoreload.py
--- a/django/template/autoreload.py
+++ b/django/template/autoreload.py
@@ -17,7 +17,7 @@ def get_template_directories():
if not isinstance(backend, DjangoTemplates):
continue
- items.update(cwd / to_path(dir) for ... | diff --git a/tests/template_tests/test_autoreloader.py b/tests/template_tests/test_autoreloader.py
--- a/tests/template_tests/test_autoreloader.py
+++ b/tests/template_tests/test_autoreloader.py
@@ -81,6 +81,17 @@ def test_reset_all_loaders(self, mock_reset):
autoreload.reset_loaders()
self.assertEqua... | Django 3.2.4+ autoreload breaks on empty string in TEMPLATES DIRS.
Description
Django versions > 3.2.3 changes the way template dirs are handled, they are now normalized using pathlib.Path.
People having an invalid value in TEMPLATESDIRS? will notice that autoreload stops working.
"DIRS": os.getenv("TEMPLATES_DIRS", ... | ["test_template_dirs_ignore_empty_path (template_tests.test_autoreloader.TemplateReloadTests)"] | ["test_get_template_directories (template_tests.test_autoreloader.Jinja2TemplateReloadTests)", "test_reset_all_loaders (template_tests.test_autoreloader.Jinja2TemplateReloadTests)", "test_watch_for_template_changes (template_tests.test_autoreloader.Jinja2TemplateReloadTests)", "test_get_template_directories (template_t... | 2022-04-09 09:38:31 | <15 min fix | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py | |
django__django-15629 | django/django | 694cf458f16b8d340a3195244196980b2dec34fd | 4.1 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -823,13 +823,15 @@ def _alter_field(
self.execute(self._delete_unique_sql(model, constraint_name))
# Drop incoming FK constraint... | diff --git a/tests/migrations/test_base.py b/tests/migrations/test_base.py
--- a/tests/migrations/test_base.py
+++ b/tests/migrations/test_base.py
@@ -65,6 +65,16 @@ def assertColumnNull(self, table, column, using="default"):
def assertColumnNotNull(self, table, column, using="default"):
self.assertFalse(... | Errors with db_collation – no propagation to foreignkeys
Description
(last modified by typonaut)
Using db_collation with a pk that also has referenced fks in other models causes foreign key constraint errors in MySQL.
With the following models:
class Account(models.Model):
id = ShortUUIDField(primary_key=True,... | It seems like this should be addressable by defining a ForeignKey.db_collation property that proxies self.target_field.db_column django/db/models/fields/related.py diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 11407ac902..f82f787f5c 100644 a b def db_type(self, connection):... | ["AlterField operation of db_collation on primary keys changes any FKs", "Creation of models with a FK to a PK with db_collation."] | ["test_reference_field_by_through_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_from_fields (migrations.test_operations.FieldOperationTests)", "test_references_field_by_name (migrations.test_operations.FieldOperationTests)", "test_references_field_by_remote_field_model (migrations.... | 2022-04-23 21:58:24 | 1-4 hours | 647480166bfe7532e8c471fef0146e3a17e6c0c9 | null | null | null | null | null | swebench_verified | py |
django__django-15731 | django/django | 93cedc82f29076c824d476354527af1150888e4f | 4.2 | diff --git a/django/db/models/manager.py b/django/db/models/manager.py
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -1,5 +1,6 @@
import copy
import inspect
+from functools import wraps
from importlib import import_module
from django.db import router
@@ -81,11 +82,10 @@ def check(self, **... | diff --git a/tests/basic/tests.py b/tests/basic/tests.py
--- a/tests/basic/tests.py
+++ b/tests/basic/tests.py
@@ -1,3 +1,4 @@
+import inspect
import threading
from datetime import datetime, timedelta
from unittest import mock
@@ -736,6 +737,17 @@ def test_manager_methods(self):
sorted(self.QUERYSET_PRO... | inspect.signature() returns incorrect signature on manager methods.
Description
(last modified by Shiva Kumar)
inspect.signature returns incorrect signature information when used on queryset methods
import inspect
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=100)
... | Tentatively accepted.
PR: https://github.com/django/django/pull/15731 | ["test_manager_method_signature (basic.tests.ManagerTest)"] | ["test_autofields_generate_different_values_for_each_instance (basic.tests.ModelInstanceCreationTests)", "test_can_create_instance_using_kwargs (basic.tests.ModelInstanceCreationTests)", "You can initialize a model instance using positional arguments,", "You can leave off the value for an AutoField when creating an", "... | 2022-05-24 12:30:05 | 15 min - 1 hour | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | null | null | null | null | null | swebench_verified | py |
django__django-15732 | django/django | ce69e34bd646558bb44ea92cecfd98b345a0b3e0 | 4.2 | diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -528,7 +528,10 @@ def alter_unique_together(self, model, old_unique_together, new_unique_together)
# Deleted uniques
for fields in olds.... | diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -2809,6 +2809,69 @@ def test_alter_unique_together_remove(self):
operation.describe(), "Alter unique_together for Pony (0 constraint(... | Cannot drop unique_together constraint on a single field with its own unique=True constraint
Description
I have an erroneous unique_together constraint on a model's primary key (unique_together = (('id',),)) that cannot be dropped by a migration. Apparently the migration tries to find all unique constraints on the co... | Can you share a traceback that shows how and where the migration fails, please.
Here it is: Traceback (most recent call last): File "./bin/django", line 56, in <module> sys.exit(djangorecipe.manage.main('project.settings.local.foobar')) File "/foo/bar/eggs/djangorecipe-1.10-py2.7.egg/djangorecipe/manage.py", line 9, in... | ["test_remove_unique_together_on_unique_field (migrations.test_operations.OperationTests)"] | ["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.... | 2022-05-24 12:58:31 | 15 min - 1 hour | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | null | null | null | null | null | swebench_verified | py |
django__django-15916 | django/django | 88e67a54b7ed0210c11523a337b498aadb2f5187 | 4.2 | diff --git a/django/forms/models.py b/django/forms/models.py
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -253,18 +253,11 @@ def __init__(self, options=None):
self.help_texts = getattr(options, "help_texts", None)
self.error_messages = getattr(options, "error_messages", None)
... | 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
@@ -3496,6 +3496,41 @@ class InheritedForm(NewForm):
type(NewForm.base_fields[name].widget),
)
+ def test_custom_callback_in_meta(self):
+ def ... | Allow ModelForm meta to specify formfield_callback.
Description
(last modified by Klaas-Jan Gorter)
The function django.forms.modelform_factory returns a form class based on the class it recieves as form argument. As an additional argument it accepts a formfield_callback function. When no callback is provided t... | I was always the impression that formfield_callback was solely an allowed kwarg of the modelform_factory function and its friends. I believe this test has been removed from version 2, because I find no equivalent test in tests/model_formsets_regress. From what I can see the patch from #18573 was never committed and thu... | ["test_custom_callback_from_base_form_meta (model_forms.tests.FormFieldCallbackTests)", "test_custom_callback_in_meta (model_forms.tests.FormFieldCallbackTests)"] | ["test_modelform_factory_metaclass (model_forms.tests.CustomMetaclassTestCase)", "Regression test for #12960. Make sure the cleaned_data returned from", "Regression for #12596: Calling super from ModelForm.clean() should be", "test_bad_callback (model_forms.tests.FormFieldCallbackTests)", "Using base forms with widgets... | 2022-08-04 18:59:18 | 15 min - 1 hour | 0fbdb9784da915fce5dcc1fe82bac9b4785749e5 | null | null | null | null | null | swebench_verified | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.