[Fixed]-Django self.client.post does not send data to view with decorator

1πŸ‘

βœ…

It turns out that the decorator has a TypeError error in this line:

session_string = args[-1] if 'session_key' in args[-1] else '[]'

So when args[-1] is not str then this should not work. Fixing it with str(args[-1]) resolves the whole issue with missing POST data.

It is weird though that self.client.post does not raise any TypeError and session_string was somehow calculated. Instead of this POST data were not sent to the view without any errors or hint warnings. POST data were just disappeared. At the same time the same code worked ok when POST request was sent from web browser, so the error remained unnoticed.

πŸ‘€Mikhail Geyer

Leave a comment