summaryrefslogtreecommitdiff
path: root/django/utils/datastructures.py
AgeCommit message (Collapse)Author
2025-08-14Fixed #36410 -- Added support for Template Partials to the Django Template ↵farhan
Language. Introduced `{% partialdef %}` and `{% partial %}` template tags to define and render reusable named fragments within a template file. Partials can also be accessed using the `template_name#partial_name` syntax via `get_template()`, `render()`, `{% include %}`, and other template-loading tools. Adjusted `get_template()` behavior to support partial resolution, with appropriate error handling for invalid names and edge cases. Introduced `PartialTemplate` to encapsulate partial rendering behavior. Includes tests and internal refactors to support partial context binding, exception reporting, and tag validation. Co-authored-by: Carlton Gibson <carlton@noumenal.es> Co-authored-by: Natalia <124304+nessita@users.noreply.github.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2025-07-23Refs #36500 -- Shortened some long docstrings and comments.Mike Edmunds
Manually reformatted some long docstrings and comments that would be damaged by the to-be-applied autofixer script, in cases where editorial judgment seemed necessary for style or wording changes.
2023-01-18Refs #34233 -- Used str.removeprefix()/removesuffix().Mariusz Felisiak
2022-02-23Fixed #33532 -- Optimized CaseInsensitiveMapping instantiation for dicts.Keryn Knight
Internal usages of this class (e.g. HttpHeaders) provide it with a dict, so testing for that type first avoids the cost of going through the potential __instancecheck__ + _abc_instancecheck to establish it's a Mapping. Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-09-22Optimized handling case-insensitive mappings.Illia Volochii
Elements yielded by _destruct_iterable_mapping_values are always unpacked. Since unpacking can be done with any iterable, there is no need to convert elements to tuples. Also, such elements can be used directly in for loops, creating a dictionary of them is excessive. Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2021-07-29Fixed 32956 -- Lowercased spelling of "web" and "web framework" where ↵David Smith
appropriate.
2021-03-10Refs #24121 -- Added __repr__() to OrderedSet.Nick Pope
2021-03-08Fixed #32517 -- Made OrderedSet reversible.Diego Lima
Refs #32516.
2020-10-30Updated MultiValueDict.update() to mirror dict.update() behavior.Nick Pope
Changes in behavior include: - Accepting iteration over empty sequences, updating nothing. - Accepting iterable of 2-tuples providing key-value pairs. - Failing with the same or comparable exceptions for invalid input. Notably this replaces the previous attempt to catch TypeError which was unreachable as the call to .items() resulted in AttributeError on non-dict objects.
2020-10-30Removed unused custom exception support for ImmutableList.Nick Pope
If the warning provided was an instance of Exception, then it would be used as-is. In practice this is untested, unused and ImmutableList is an undocumented internal datastructure.
2019-02-06Fixed #30159 -- Removed unneeded use of OrderedDict.Nick Pope
Dicts preserve order since Python 3.6.
2019-01-16Fixed #20147 -- Added HttpRequest.headers.Santiago Basulto
2018-10-14Fixed typo in django/utils/datastructures.py.Taoufik
2018-02-26Refs #28909 -- Simplifed code using unpacking generalizations.Mariusz Felisiak
2018-01-12Fixed #28996 -- Simplified some boolean constructs and removed trivial ↵Дилян Палаузов
continue statements.
2017-09-07Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."Tim Graham
This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better.
2017-08-23Used OrderedDict.fromkeys() to initialize OrderedDict with None values.Sergey Fedoseev
2017-06-28Fixed #27818 -- Replaced try/except/pass with contextlib.suppress().Mads Jensen
2017-05-27Fixed #28249 -- Removed unnecessary dict.keys() calls.Jon Dufresne
iter(dict) is equivalent to iter(dict.keys()).
2017-04-11Fixed #28064 -- Removed double-quoting of key names in MultiValueDictKeyError.petedmarsh
2017-04-07Made MultiValueDict.__deepcopy__()'s memo kwarg an arg.Daniel F Moisset
It's always provided.
2017-02-11Refs #27656 -- Updated django.utils docstring verbs according to PEP 257.Anton Samarchyan
2017-02-01Refs #23919 -- Replaced kwargs.pop() with keyword-only arguments.Vytis Banaitis
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2017-01-19Refs #23919 -- Removed __nonzero__() methods (for Python 2).Simon Charette
Thanks Tim for the review.
2017-01-19Refs #23919 -- Stopped inheriting from object to define new style classes.Simon Charette
2017-01-18Refs #23919 -- Removed most of remaining six usageClaude Paroz
Thanks Tim Graham for the review.
2017-01-18Refs #23919 -- Removed six.PY2/PY3 usageClaude Paroz
Thanks Tim Graham for the review.
2016-12-09Fixed #27583 -- Fixed MultiValueDict.getlist() crash when values for key is ↵Mariusz Felisiak
None. Restored the behavior before 727d7ce6cba21363470aaefb2dc5353017531be3.
2016-09-16Fixed #27198 -- Made MultiValueDict.getlist() return a new list to prevent ↵Jani Tiainen
mutation.
2015-07-09Fixed #25093 -- Added utils.datastructures.OrderedSet.__len__()darkryder
2015-01-17Removed django.utils.datastructures.SortedDict per deprecation timeline.Tim Graham
2015-01-17Removed django.utils.datastructures.MergeDict per deprecation timeline; refs ↵Tim Graham
#18659.
2014-12-08Fixed #23968 -- Replaced list comprehension with generators and dict ↵Jon Dufresne
comprehension
2014-10-16Fixed #23664 -- Provided a consistent definition for OrderedSet.__bool__Thomas Chaumeny
This also defines QuerySet.__bool__ for consistency though this should not have any consequence as bool(qs) used to fallback on QuerySet.__len__ in Py3.
2014-09-05Revert "Fixed #23384 -- Allowed overriding part of a dictionary-type setting"Claude Paroz
This reverts commit 66757fee7e921ad4c35e0b3f80c25e026100b31c. Discussions have led to think that this functionality does not bring significant benefits to justify the added complexity. Read also discussions on ticket #22734.
2014-08-30Fixed #23384 -- Allowed overriding part of a dictionary-type settingClaude Paroz
This change is needed for upcoming changes where settings might be grouped in a parent dictionary. Thanks Tim Graham for the review.
2014-03-08Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warningsClaude Paroz
Thanks Anssi Kääriäinen for the idea and Simon Charette for the review.
2013-11-02Correct flake8 E302 violationsRay Ashman Jr
2013-10-23Fixed E225 pep8 warnings.Tim Graham
2013-10-22Fixed E221 pep8 warnings.Tim Graham
2013-10-17Fixed #18659 -- Deprecated request.REQUEST and MergeDictBouke Haarsma
Thanks Aymeric Augustin for the suggestion.
2013-09-18Fixed #15625 -- Made message in MultiValueDictKeyError less verbose.Tim Graham
Thanks margieroginski for the suggestion.
2013-08-30Fixed #20989 -- Removed useless explicit list comprehensions.Simon Charette
2013-08-29Fixed #20989 -- Removed explicit list comprehension inside dict() and tuple()Tim Graham
Thanks jeroen.pulles at redslider.net for the suggestion and helper script.
2013-08-10Docs tweaks (thanks timgraham)Andrew Godwin
2013-08-10Back SortedSet onto OrderedDict, rename it, and a few typo fixesAndrew Godwin
2013-08-09Merge remote-tracking branch 'core/master' into schema-alterationAndrew Godwin
Conflicts: django/core/management/commands/flush.py django/core/management/commands/syncdb.py django/db/models/loading.py docs/internals/deprecation.txt docs/ref/django-admin.txt docs/releases/1.7.txt
2013-08-04Deprecated SortedDict (replaced with collections.OrderedDict)Curtis Maloney
Thanks Loic Bistuer for the review.