{{{
TypeError: expected string or bytes-like object
}}}
instead of causing the default `content_type` value. It would be more
user-friendly if passing `None` resulted in the default value.
One reason is as follows. Currently, if one wants to create a wrapper
function around `post()` with the same default behavior, the user either
needs to (1) duplicate / hard-code the default value in their wrapper
function, or (2) special-case `None` with a second invocation of `post()`
using a different function signature (i.e. one that doesn't pass //any//
`content_type` value). You can even see this happening in `client.py` with
the way that `Client.post()` invokes `RequestFactory.post()` -- the
default needs to be hard-coded twice.
--
Ticket URL: <https://code.djangoproject.com/ticket/29268>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Should the same design be used for the other HTTP methods that have
`content_type='application/octet-stream'`?
--
Ticket URL: <https://code.djangoproject.com/ticket/29268#comment:1>
Comment (by Chris Jerdonek):
Oh, good observation. I didn't examine the other methods. Yes, I do.
Generally, I've found this type of style / pattern helpful anywhere an API
has a default value. Perhaps other areas of Django could use a similar
treatment. Might it be a candidate for the
[https://docs.djangoproject.com/en/dev/internals/contributing/writing-code
/coding-style/ style guide]?
--
Ticket URL: <https://code.djangoproject.com/ticket/29268#comment:2>
* owner: nobody => Chris Jerdonek
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29268#comment:3>
Comment (by Chris Jerdonek):
I started working on this here:
https://github.com/cjerdonek/django/tree/ticket_29268
--
Ticket URL: <https://code.djangoproject.com/ticket/29268#comment:4>
* owner: Chris Jerdonek => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/29268#comment:5>