GMail
unread,Dec 26, 2016, 12:57:27 AM12/26/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-d...@googlegroups.com
Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
I noticed, that HttpRequest.__repr__ method relies on 'Content-Type' header:
> class HttpResponse(HttpResponseBase):
> ...
>
> def __repr__(self):
> return '<%(cls)s status_code=%(status_code)d, "%(content_type)s">' % {
> 'cls': self.__class__.__name__,
> 'status_code': self.status_code,
> 'content_type': self['Content-Type'],
> }
And after deleting an object in DRF sends empty response with HTTP204 and no 'Content-Type' header. I was trying to log outgoing response and got KeyError here.
So I have two questions:
1. Is this intentional? Do all responses in Django have 'Content-Type' header and should DRF be aware of it?
2. Why not use `str.format` here? To avoid errors like this, `dict` subclass with `__missing__` method could be used.