Before this commit, child validation errors returned from ListField
would be held in a dictionary with the list index as an integer key.
This commit changes it so that the key is converted to str before being
used as a key.
The motivation for this is that rapidjson (an alternative python json
package) doesn't allow converting dicts with anything other than str
keys (i.e., it does not do any type conversion). Other json packages
(json, ujson, simplejson) tend to allow this and just do the type
conversion themselves. With this fix, json, ujson and simplejson will
continue to work as before, but rapidjson will become compatible
out-of-the-box without having to process the dictionary before rendering
to json.
One could perhaps argue that this conversion should rather be done in
rapidjson itself, or perhaps in glue/adapter code (e.g. in some
RapidJSONRenderer implementation); but then again, this seems like an
easy fix that hopefully doesn't break much, and saves a potentially
costly tree traversal in the renderer.
Existing tests have been updated to match this change in behavior. I
guess a new test using rapidjson could be useful, but I don't know what
DRF's policy is on integration tests that interface with third-party
libraries is.
see https://github.com/encode/django-rest-framework/issues/5660
Trying to register new routes on a router after having accessed the
router `urls` attribute leads to surprising results.
The route is added without error to the router's `registry` but the urls
are not updated, because they are cached in `_urls`.
This commit invalidates the cache after each new registration.
* Add test that verifies that HTML is correctly escaped in Browsable API views
* Fix `urlize_quoted_links` tag to avoid double escaping in autoescape mode
* Fix XSS in default DRF Browsable API template by re-enabling autoescape
* Fix issue1811: take limit_choices_to into account with FK
* Issue 1811: Add tests to illustrate issue
* Filter queryset only if limit_choices_to exists
* Move test_relations_with_limited_querysets file within test_relations_pk
* move limit_choices_to logic from relations.py to utils/field_mapping.py
* move limit_choices_to above other check to avoid conflicts
* compat: (py2) urlparse = urllib.parse (py3)
We were mistakenly importing the 'urlparse' function from the Python 2
'urlparse' module, as opposed to the module itself. Correct this.
Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #6261
* compat: Remove 'compat.urlparse'
We can just use Django's vendored six library, like we do everywhere
else.
Signed-off-by: Stephen Finucane <stephen@that.guru>
* Update quickstart to Django 2.0 routing syntax
* Remove uneccessary raw string identifiers
* Correctly import path function
* Fix import path to use django.urls
This is what is prescribed in the Django 2.1 tutorial
In some cases we end with an operation between two `OperandHolder`.
This didn't work as it didn't knew how to deal with | or &
This fixes by adding those operations.
* Fix typo in generators.py
* Fix typo in inspectors.py
* message line too long
* Change backslash to multiline strings
* Removed trailing whitespace from assertion message