Commit Graph

471 Commits

Author SHA1 Message Date
Mariusz Felisiak 4a43335d30
Fixed #30086, Refs #32873 -- Made floatformat template filter independent of USE_L10N. 2021-09-08 08:37:27 +02:00
Matt Westcott 5092f7247d Fixed #33036 -- Made simple_tag()/inclusion_tag() with takes_context raise TemplateSyntaxError when function has no parameters. 2021-08-19 07:39:55 +02:00
Mariusz Felisiak 65ed96fa39 Refs #33002 -- Added DebugLexer/Lexer.tokenize() test for trailing text token. 2021-08-09 13:42:26 +02:00
Chris Jerdonek b2be7e12cc Refs #33002 -- Made template_tests.tests.py's tests test both Lexer and DebugLexer. 2021-08-09 13:37:02 +02:00
Greg Twohig c99aaf14ee Refs #32990 -- Added tests for DebugLexer/Lexer.tokenize(). 2021-08-09 08:21:37 +02:00
Mariusz Felisiak 34d5336b9d Added test for TemplateSyntaxError when variables begin with underscores. 2021-08-02 11:37:39 +02:00
David Smith f9b7704ab3
Refs #32956 -- Corrected spelling of "gray". 2021-08-02 07:51:24 +02:00
David Smith 1cba320786
Refs #32956 -- Changed "afterwards" to "afterward" in docs and comments.
This also removes unnecessary comments with the previous spelling.

AP Stylebook has a short entry to advise the preferred spelling for
"en-us". "Afterwards" is preferred in British English.
2021-07-27 10:41:51 +02:00
cammil 313c3d1aa1 Fixed #28935 -- Fixed display of errors in extended blocks.
Get the template that caused the exception and get the
exception info from that template, using the node that
caused the exception.
2021-07-02 11:38:15 +02:00
Keryn Knight 854e9b0668 Fixed #32824 -- Improved performance of NodeList.render().
This avoids the following:
 - checking that each item in the nodelist is a subclass of Node,
 - calling str() on the render_annotated() output, because it's
   documented that Node.render() must return a string,
 - calling mark_safe() on the output, when the value to be wrapped is
   definitively known to be a string because the result of ''.join()
   is always of that type,
 - using an intermediate list to store each individual string.
2021-06-11 12:22:06 +02:00
saeedblanchette 66ed03e7c9 Refs #24121 -- Added __repr__() to AdminForm, BlockContext, BlockTranslateNode, and IncludeNode. 2021-06-10 12:47:53 +02:00
abhiabhi94 c609d5149c Refs #24121 -- Added __repr__() to Engine 2021-06-01 07:44:36 +02:00
Hasan Ramezani 68357b2ca9 Fixed #32744 -- Normalized to pathlib.Path in autoreloader check for template changes. 2021-05-26 09:41:29 +02:00
saeedblanchette e6406853c3 Refs #24121 -- Added__repr__() to StaticNode. 2021-05-12 08:41:52 +02:00
Tiago Honorato 4f4f770f77 Refs #24121 -- Added __repr__() to Origin and Template. 2021-03-17 07:49:55 +01:00
François Freitag 7ca7f4495b Refs #21429 -- Added SimpleTestCase.assertNoLogs() on Python < 3.10. 2021-03-02 20:35:33 +01:00
Rohith PR d3ecef26b9 Refs #24121 -- Added __repr__() to URLNode. 2021-03-02 12:24:49 +01:00
David Smith 179ee13eb3 Refs #24121 -- Added __repr__() to FilterExpression, Lexer, Parser, and Token. 2021-02-26 10:25:08 +01:00
Markus Holtermann 50a5f8840f Refs #32394 -- Changed STATIC_URL/MEDIA_URL to relative paths in tests and docs where appropriate. 2021-02-06 13:41:35 +01:00
Hasan Ramezani c978dd93fd Fixed #32290 -- Fixed TemplateNotFound in {% include %} tag for relative path in variable. 2021-01-27 10:07:31 +01:00
Hasan Ramezani 640a6e1dce Refs #32290 -- Added {% extends %} test for relative path in variable. 2021-01-27 09:37:03 +01:00
Mariusz Felisiak e7208f13c0 Refs #25236 -- Removed {% ifequal %} and {% ifnotequal %} template tags per deprecation timeline. 2021-01-14 17:50:04 +01:00
Hasan Ramezani 577f2338f1 Fixed #32208 -- Allowed adding lazy() objects.
Co-authored-by: Claude Paroz <claude@2xlibre.net>
2020-12-21 09:24:41 +01:00
Daniel Hahler c70cd2a926 Refs #15053 -- Clarified debug message when skipping templates to avoid recursion. 2020-11-21 10:49:31 +01:00
Nick Pope 477c800443
Changed docs and a code comment to use gender-neutral pronouns.
Follow up to e1b7723817.
2020-11-13 22:26:30 +01:00
Tom Forbes 658bcc16f1 Fixed #25791 -- Implement autoreload behaviour for cached template loader. 2020-11-05 15:30:52 +01:00
Tom Forbes 29845ecf69 Refs #25791 -- Added get_dirs() method to cached template loader. 2020-11-05 15:30:52 +01:00
Jacob Walls ac6c426007 Fixed #20601 -- Allowed forcing format with thousand separators in floatformat filter.
Thanks Claude Paroz and Nick Pope for reviews.
2020-10-13 10:36:46 +02:00
Tom Carrick dcb69043d0 Fixed #32002 -- Added headers parameter to HttpResponse and subclasses. 2020-10-07 09:19:57 +02:00
Jacob Walls 01a7af09b9 Fixed #18995 -- Made blocktranslate tag raise TemplateSyntaxError when plural count is not a number. 2020-09-29 08:03:51 +02:00
Tom Carrick bcc2befd0e Fixed #31789 -- Added a new headers interface to HttpResponse. 2020-09-14 08:41:59 +02:00
Jon Dufresne 81d69568a6 Made test_once a keyword argument in template_tests.utils.setup().
Replaces the kwargs.get(...) pattern. Helps avoid typos by providing a
better error message in case of misuse.
2020-05-21 08:09:19 +02:00
David Smith 03537e2458
Completed lorem tag test coverage. 2020-05-14 12:36:38 +02:00
Jon Dufresne 72a170b4c3 Fixed #25236 -- Deprecated {% ifequal %} and {% ifnotequal %} template tags.
The {% if %} tag provides all features of these tags.

Since Django 1.2 (May 17, 2010), the docs have hinted that
{% ifequal %} and {% ifnotequal %} will be deprecated in a future
Django version. Time to make it official.
2020-05-11 09:07:33 +02:00
Jon Dufresne d8cb8fdf40 Switched unittest.TestCase to SimpleTestCase in template_tests/test_nodelist.py. 2020-05-11 07:56:11 +02:00
Nick Pope 8f10ceaa90 Changed `'%s' % value` pattern to `str(value)`. 2020-05-04 08:27:18 +02:00
Jon Dufresne 505fec6bad Capitalized Unicode in docs, strings, and comments. 2020-04-20 12:10:33 +02:00
Claude Paroz 4d973f5939 Refs #26601 -- Deprecated passing None as get_response arg to middleware classes.
This is the new contract since middleware refactoring in Django 1.10.

Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-02-18 20:03:44 +01:00
Keshav Kumar f37d548ede Fixed #20995 -- Added support for iterables of template names to {% include %} template tag.
Thanks Adam Johnson for the review.
2020-02-18 06:56:05 +01:00
Hasan Ramezani fc4f45ebdc Used assertRaisesMessage() in various tests. 2020-02-07 12:46:23 +01:00
Patrick Seebauer e3d546a1d9 Fixed #31128 -- Fixed TemplateSyntaxError in simple_tag() and inclusion_tag() for kwargs. 2020-01-02 10:44:07 +01:00
Mike Hansen 35d36d9462 Refs #30585 -- Updated project templates and tests to use (block)translate tags. 2019-12-18 13:15:38 +01:00
Mike Hansen d291c72bf2 Fixed #30585 -- Added {% translate %} and {% blocktranslate %} template tags. 2019-12-18 13:15:38 +01:00
Jon Dufresne aa12cf07c9 Removed unnecessary numeric indexes in format strings. 2019-11-19 08:29:47 +01:00
Jon Dufresne 39791c8e6d Harmonized Windows checks in tests to a single style. 2019-11-06 15:14:30 +01:00
Sky 3cf907c20c Fixed #30761 -- Prevented floatformat filter from returning a negative zero. 2019-10-31 10:48:35 +01:00
Sky 459de8dc29 Added more tests for floatformat filter with negative values. 2019-10-31 10:07:59 +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
ElizabethU 54ea290e5b Fixed #30651 -- Made __eq__() methods return NotImplemented for not implemented comparisons.
Changed __eq__ to return NotImplemented instead of False if compared to
an object of the same type, as is recommended by the Python data model
reference. Now these models can be compared to ANY (or other objects
with __eq__ overwritten) without returning False automatically.
2019-10-01 17:58:19 +02:00
Mads Jensen 129583a0d3 Removed some outdated backwards compatibility imports and misleading comments.
EmptyResultSet moved in 46509cf13d.
FieldDoesNotExist moved in 8958170755.
BoundField and pretty_name moved in 8550161e53.
EMPTY_VALUES moved in 471596fc1a.
BaseRunserverCommand moved in 5c53e30607.
2019-09-24 15:18:53 +02:00
Florian Apolloner 7f65974f82 Fixed CVE-2019-14232 -- Adjusted regex to avoid backtracking issues when truncating HTML.
Thanks to Guido Vranken for initial report.
2019-08-01 09:24:54 +02:00
Andrew Godwin a415ce70be Fixed #30451 -- Added ASGI handler and coroutine-safety.
This adds an ASGI handler, asgi.py file for the default project layout,
a few async utilities and adds async-safety to many parts of Django.
2019-06-20 12:29:43 +02:00
Jon Dufresne 53ea535f13 Refs #27486 -- Added tests for filesizeformat filter. 2019-06-11 20:18:36 +02:00
Jon Dufresne e065b29387 Refs #27804 -- Used subTest() in filesizeformat tests and HumanizeTests. 2019-06-10 08:46:11 +02:00
Batuhan Taşkaya 5c19274643 Fixed #30453 -- Fixed crash of simple_tag() and inclusion_tag() when function is wrapped.
getfullargspec() doesn't work with wrapped functions.
2019-05-17 09:53:24 +02:00
Tobias Kunze e683613649 Fixed #20122 -- Made pluralize template filter return '' on invalid input. 2019-05-03 11:35:20 +02:00
Jon Dufresne 8d76443aba Fixed #30399 -- Changed django.utils.html.escape()/urlize() to use html.escape()/unescape(). 2019-04-25 15:09:07 +02:00
Nathan Gaberel 624573726a Fixed #29791 -- Made Engine.render_to_string() honor autoescape. 2019-03-25 17:59:07 -04:00
Mariusz Felisiak b435f82939
Reverted "Fixed relative paths imports per isort 4.3.5."
This reverts commit 463fe11bc8 due to
restore of relative paths sorting from isort < 4.3.5 in isort 4.3.10.
2019-03-03 19:33:48 +01:00
Mariusz Felisiak 463fe11bc8
Fixed relative paths imports per isort 4.3.5. 2019-02-25 11:03:30 +01:00
Tim Graham 0ac4e51b2c Fixed typos in tests/template_tests/test_context.py. 2019-02-21 09:43:00 -05:00
Sergey Fedoseev 1933e56eca Removed uneeded generator expressions and list comprehensions. 2019-02-09 09:18:48 -05:00
Sergey Fedoseev b1a2ad6925 Removed uneeded iter() calls with generator expression as argument. 2019-02-09 09:18:22 -05:00
Tim Graham 9a0cc54524
Refs #30137 -- Fixed template test on Windows.
Broken in 7785e03ba8.
2019-01-29 10:05:10 -05:00
Jon Dufresne 7785e03ba8 Fixed #30137 -- Replaced OSError aliases with the canonical OSError.
Used more specific errors (e.g. FileExistsError) as appropriate.
2019-01-28 11:15:06 -05:00
Tim Graham 043bd70942 Updated test URL patterns to use path() and re_path(). 2018-12-31 10:47:32 -05:00
Simon Charette 0f212db29d Made reused RequestFactory instances class attributes. 2018-11-27 09:49:02 -05:00
Simon Charette b8763fc0a4 Used SimpleTestCase for template library tests. 2018-11-26 10:23:35 -05:00
Tim Graham 70a80ff1be Added a urlize test for wrapping characters. 2018-10-12 08:13:52 +02:00
Sergey Fedoseev 8ef8bc0f64 Refs #28909 -- Simplifed code using unpacking generalizations. 2018-09-28 09:57:12 -04:00
Jon Dufresne bb81c22d90 Refs #27795 -- Removed force_bytes() usage in utils/_os.py. 2018-09-25 11:27:36 -04:00
Claude Paroz 201017df30 Fixed #29654 -- Made text truncation an ellipsis character instead of three dots.
Thanks Sudhanshu Mishra for the initial patch and Tim Graham for the review.
2018-08-21 17:46:45 +02:00
luz.paz 97e637a87f Fixed typos in comments and docs. 2018-08-01 16:09:22 -04:00
Dražen Odobašić 9f3b9ffd51 Fixed #29617 -- Fixed Template crash if template_string is lazy.
Regression in 3a148f958d.
2018-07-31 09:57:11 -04:00
Hasan Ramezani cebbcaa1ba Moved yesno filter test to its file. 2018-07-27 17:15:00 -04:00
ryabtsev b4fd9b5ad4 Fixed #29432 -- Allowed passing an integer to the slice template filter. 2018-05-26 20:56:51 -04:00
Ryan Rubin a8d12bc280 Fixed #29400 -- Fixed crash in custom template filters that use decorated functions.
Regression in 620e9dd31a.
2018-05-25 11:11:46 -04:00
Claude Paroz 9c4ea63e87
Replaced TOKEN_* constants by TokenType enums.
Thanks Tim Graham for the review.
2018-05-10 17:51:51 +02:00
Claude Paroz 523e04dfeb Captured logging in tests with self.assertLogs(). 2018-05-07 09:34:02 -04:00
Tim Graham a917a5601f Refs #23890 -- Removed numpy deprecation warning silencing.
Obsolete since numpy 1.12.0.
2018-04-18 22:09:26 -04:00
Jirka Vejrazka 6148dda72f Fixed #29288 -- Made {% widthratio %} assign to as var if an exception occurs. 2018-04-04 14:03:16 -04:00
Hasan Ramezani 76ae1e9a94 Increased test coverage for {% get_admin_log %} and {% static %}. 2018-03-26 13:34:23 -04:00
Mads Jensen 4554f9a783 Increased test coverage for various template tags. 2018-03-24 19:56:46 -04:00
Mads Jensen bb79e480e1 Increased test coverage for i18n template tags. 2018-03-21 08:38:07 -04:00
Mariusz Felisiak 362813d628
Fixed hanging indentation in various code. 2018-03-16 10:54:34 +01:00
Hasan Ramezani 5033999153 Fixed #29154 -- Corrected examples in pluralize docstring and added tests. 2018-02-23 14:20:00 -05:00
Jonas Haag 8c709d79cb Fixed #17419 -- Added json_tag template filter. 2018-02-07 18:38:12 -05:00
Mariusz Felisiak 9bcf73d788 Fixed imports per isort 4.3.0. 2018-02-01 09:29:46 +01:00
Roger Gammans d0b44c44ef Fixed #29060 -- Made {% firstof %} assign '' to the asvar if all inputs are false. 2018-01-25 13:40:51 -05:00
Jon Dufresne ff05de760c Fixed #29038 -- Removed closing slash from HTML void tags. 2018-01-21 02:09:10 -05:00
Levi Payne 6c3104221b Refs #28721 -- Added test for variations of 'inf'/'infinity' as a template variable names.
Fixed by 9ec7d8e514.
2017-10-21 20:55:26 -04:00
Claude Paroz 9ec7d8e514 Fixed #28730 -- Fixed loss of precision for large integer literals in templates
Thanks Fraser Nevett for the report and Tim Graham for patch edits.
2017-10-21 17:20:29 +02:00
Mads Jensen f7036b3e26 Fixed #28662 -- Silenced join template filter error if arg isn't iterable. 2017-10-20 09:46:31 -04:00
Tim Graham 1399f8ae77 Refs #28711 -- Replaced ugettext_lazy() with gettext_lazy() in a test.
As per c651331b34.
2017-10-18 20:07:36 -04:00
Jonas Haag d997ab7764 Fixed #28711 -- Fixed unordered_list template filter with lazy translations. 2017-10-18 19:45:10 -04:00
Jonas Haag b21b1b10af Refs #23260 -- Tested nested generator input to unordered_list template filter. 2017-10-18 19:37:30 -04:00
Mads Jensen 86367a11d3 Added tests for invalid {% for %} usage and ForLoop.__repr__(). 2017-10-05 11:33:14 -04:00
Mads Jensen aba3467585 Added tests for invalid {% autoescape %} usage. 2017-10-02 11:02:58 -04:00
Mads Jensen 25307089bc Completed test coverage for default template filters. 2017-09-30 18:34:51 -04:00
Tim Graham e62165b898 Refs #27175 -- Removed exception silencing from the {% include %} template tag.
Per deprecation timeline.
2017-09-22 12:51:18 -04:00