Commit Graph

212 Commits

Author SHA1 Message Date
Hasan Ramezani 47651eadb8 Fixed #30583 -- Fixed handling JSONFields in XML serializer.
Co-authored-by: Chason Chaffin <chason@gmail.com>
2020-06-17 11:12:18 +02:00
Sasha Pachev 38a21f2d9e
Fixed #31663 -- Made DecimalField.to_python() handle non-numeric invalid values. 2020-06-05 21:13:36 +02:00
Tim Graham f59a2b7306
Refs #12990 -- Added DatabaseFeatures.has_json_operators.
CockroachDB also has them.
2020-05-18 08:12:20 +02:00
sage 6789ded0a6 Fixed #12990, Refs #27694 -- Added JSONField model field.
Thanks to Adam Johnson, Carlton Gibson, Mariusz Felisiak, and Raphael
Michel for mentoring this Google Summer of Code 2019 project and
everyone else who helped with the patch.

Special thanks to Mads Jensen, Nick Pope, and Simon Charette for
extensive reviews.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-05-08 07:23:31 +02:00
Nick Pope 335c9c94ac Simplified imports from django.db and django.contrib.gis.db. 2020-02-04 13:20:06 +01:00
Mariusz Felisiak 2e6dc72d83
Used temporary directory in FileFieldTests.test_pickle().
Using the current directory caused a PermissionError.
2020-01-31 20:33:48 +01:00
Hasan Ramezani a97111eabf Fixed 31207 -- Prevented references to non-local remote fields in ForeignKey.to_field.
Thanks Simon Charette for the initial patch and review.
2020-01-31 10:19:12 +01:00
Carlton Gibson 29c126bb34 Fixed #31124 -- Fixed setting of get_FOO_display() when overriding inherited choices.
Regression in 2d38eb0ab9
2020-01-15 15:35:22 +01:00
Carlton Gibson 4c1b401e82 Added file cleanup in FileFieldTests.test_pickle(). 2020-01-09 20:47:45 +01:00
Hasan Ramezani f600e3fad6 Fixed #21238 -- Fixed restoring attributes when pickling FileField and ImageField. 2020-01-09 09:37:59 +01:00
Hasan Ramezani aaea9deac4 Refs #21238 -- Added more tests for pickling FileField and ImageField. 2020-01-09 09:18:53 +01:00
Hasan Ramezani 66e16dcc99 Removed unused lines in ImageFieldTests.test_pickle(). 2020-01-09 08:44:39 +01:00
Mariusz Felisiak 5a68f02498
Fixed random models_fields.test_uuid.TestQuerying failures.
Random failures depended on a generated UUID.
2019-12-27 15:25:50 +01:00
Caio Ariede 555bebe774 Fixed #30987 -- Added models.PositiveBigIntegerField. 2019-11-19 09:34:11 +01:00
Jon Dufresne 77aa74cb70 Refs #29983 -- Added support for using pathlib.Path in all settings. 2019-11-07 10:26:22 +01:00
Jon Dufresne 39791c8e6d Harmonized Windows checks in tests to a single style. 2019-11-06 15:14:30 +01:00
Carlton Gibson 2d38eb0ab9 Fixed #30931 -- Restored ability to override Model.get_FIELD_display().
Thanks Sergey Fedoseev for the implementation idea.

Regression in a68ea23101.
2019-11-04 07:55:34 +01:00
Nick Pope 7552de7866 Used more specific unittest assertions in tests.
* assertIsNone()/assertIsNotNone() instead of comparing to None.
* assertLess() for < comparisons.
* assertIs() for 'is' expressions.
* assertIsInstance() for isinstance() expressions.
* rounding of assertAlmostEqual() for round() expressions.
* assertIs(..., True/False) instead of comparing to True/False.
* assertIs()/assertIsNot() for ==/!= comparisons.
* assertNotEqual() for == comparisons.
* assertTrue()/assertFalse() instead of comparing to True/False.
2019-10-29 12:37:30 +01:00
Dan Moore bc94e3c1a2 Fixed #29919 -- Fixed RelatedOnlyFieldListFilter crash with reverse relationships. 2019-10-23 10:50:31 +02:00
Dan Moore f3855a8d2d Added tests for Field.get_choices()'s limit_choices_to argument. 2019-10-23 10:47:17 +02:00
Jon Dufresne 2f72480fbd Replaced deprecated assertEquals() with assertEqual(). 2019-10-21 07:52:17 +02:00
Ian Foote d9881a025c Fixed #29915 -- Added support for values with hyphens to pattern lookups for UUIDField on backends without UUID datatype.
Support hyphens in iexact, contains, icontains, startswith, istartswith,
endswith and iendswith UUIDField filters on backends without UUID
datatype.
2019-09-23 08:24:08 +02:00
Ian Foote 485f65b3c0 Refs #29915 -- Added tests for using pattern lookups with values without hyphens for UUIDField. 2019-09-23 08:24:00 +02:00
Shai Berger 72ebe85a26 Fixed #27910 -- Added enumeration helpers for use in Field.choices.
These classes can serve as a base class for user enums, supporting
translatable human-readable names, or names automatically inferred
from the enum member name.

Additional properties make it easy to access the list of names, values
and display labels.

Thanks to the following for ideas and reviews:

Carlton Gibson, Fran Hrženjak, Ian Foote, Mariusz Felisiak, Shai Berger.

Co-authored-by: Shai Berger <shai@platonix.com>
Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-09-04 14:42:49 +02:00
Nick Pope 21e559495b Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin and refactored AutoFields.
This reduces duplication by allowing AutoField, BigAutoField and
SmallAutoField to inherit from IntegerField, BigIntegerField and
SmallIntegerField respectively. Doing so also allows for enabling the
max_length warning check and minimum/maximum value validation for auto
fields, as well as providing a mixin that can be used for other possible
future auto field types such as a theoretical UUIDAutoField.
2019-08-20 09:22:25 +02:00
zeyneloz 00035672a4 Fixed #30449 -- Fixed RelatedFieldListFilter/RelatedOnlyFieldListFilter to respect model's Meta.ordering.
Regression in 6d4e5feb79.

Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-08-15 10:29:05 +02:00
Diederik van der Boor 25f21bd237 Fixed #28393 -- Added helpful error messages for invalid AutoField/FloatField/IntegerField values.
Co-authored-by: Diederik van der Boor <vdboor@edoburu.nl>
Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
2019-08-05 08:41:29 +02:00
Jon Dufresne 42b9a23267 Fixed #30400 -- Improved typography of user facing strings.
Thanks Claude Paroz for assistance with translations.
2019-06-28 16:46:18 +02:00
Jon Dufresne 498092377b Refs #27804 -- Used subTest() in BinaryFieldTests.test_set_and_retrieve. 2019-06-07 06:04:56 +02:00
Mykola Kokalko ef082ebb84 Fixed #29529 -- Allowed models.fields.FilePathField to accept a callable path. 2019-05-02 11:11:56 +02:00
Mykola Kokalko 11971cd87c Added tests for setting models.fields.FilePathField.path. 2019-05-02 11:11:50 +02:00
Scott Fitsimones a14c0fda15 Fixed #30328 -- Fixed crash of IntegerField.validators when limit_value in a custom validator is callable. 2019-04-19 07:58:27 +02:00
Matthias Kestenholz ea60b7bc74 Removed redundant model field choices tests. 2019-03-23 12:04:39 -04:00
Simon Charette 218a485bf1 Refs #12663 -- Fixed reference to nonexistent field in model_fields tests. 2019-03-17 20:49:32 -04:00
avas9366 9681e968eb Fixed #30232 -- Corrected expected format in invalid DurationField error message. 2019-03-04 19:25:27 -05:00
Joshua Cannon 16a5a2a2c8 Fixed #30076 -- Added Model.get_FOO_display() even if field's choices are empty. 2019-01-30 13:44:10 -05:00
Simon Charette 84e7a9f4a7 Switched setUp() to setUpTestData() where possible in Django's tests. 2018-11-27 09:35:17 -05:00
Tim Graham 193c109327 Switched TestCase to SimpleTestCase where possible in Django's tests. 2018-11-27 08:58:44 -05:00
Hasan Ramezani 6d4e5feb79 Fixed #29835 -- Made RelatedFieldListFilter respect ModelAdmin.ordering. 2018-11-14 14:29:39 -05:00
Sanyam Khurana 83c7096f2a Fixed #29869 -- Made UUIDField.to_python() convert integers. 2018-10-24 20:26:57 -04:00
Simon Charette 5e3463f6bc Fixed #27595 -- Made ForeignKey.get_col() follow target chains.
Previously, foreign relationships were followed only one level deep which
prevents foreign keys to foreign keys from being resolved appropriately.
This was causing issues such as improper database value conversion for
UUIDField on SQLite because the resolved expression's output field's
internal type wasn't correct. Added tests to make sure unlikely foreign
reference cycles don't cause recursion errors.

Refs #24343.

Thanks oyooyo for the report and Wayne Merry for the investigation.
2018-10-22 09:49:34 -04:00
Jon Dufresne b3b47bf515 Added tests for using bytearray with BinaryField and corrected docs. 2018-10-01 09:16:16 -04:00
Sergey Fedoseev 8ef8bc0f64 Refs #28909 -- Simplifed code using unpacking generalizations. 2018-09-28 09:57:12 -04:00
Jon Dufresne fb2964a410 Added test of filtering on BinaryField and corrected docs. 2018-09-26 14:38:12 -04:00
orlnub123 21420096c4 Fixed #29247 -- Allowed blank model field choice to be defined in nested choices. 2018-04-20 11:06:14 -04:00
Tim Graham e35004966b Moved tests for model Field.get_choices(). 2018-04-20 11:05:25 -04:00
Tim Graham 5fa4f40f45 Fixed #29227 -- Allowed BooleanField to be null=True.
Thanks Lynn Cyrin for contributing to the patch, and Nick Pope for review.
2018-03-20 12:10:10 -04:00
Mariusz Felisiak 362813d628
Fixed hanging indentation in various code. 2018-03-16 10:54:34 +01:00
Sergey Fedoseev ae6fa914aa Fixed #28926 -- Fixed loss of precision of big DurationField values on SQLite and MySQL. 2017-12-28 17:35:41 -05:00
Cameron Curry 622ead6aaf Fixed #28937 -- Allowed BinaryField to be editable=True. 2017-12-22 16:31:46 -05:00