Задать вопрос

Тел: +7 965 3737 888





Add Extra Headers to Test Client Requests

As Simon Willison mentions in his Debugging Django presentation, using the Test Client in the interpreter can be a great way to take a peek at the raw results from a view. In some cases you may need to add additional headers to the request (for instance a piece of middleware may rely on them).

Though it is not mentioned in the reference documentation, a quick peek at the code confirmed my hopes that it would be possible to add data to the request. The Client get and post methods both accept an extra kwargs parameter that allow you to populate the request with additional data.

Вопрос полезен? Да0/Нет0