tomchristie/django-rest-framework — Issue #85: crsf check fails if posted data is not a dictionary
Author: sebpiq
Created: 2011-11-06 16:28:39+00:00
State: open

in *djangorestframework/authentication.py:98* :

```python
request._post = self.view.DATA
resp = CsrfViewMiddleware().process_view(request, None, (), {})
```

This fails if *DATA* isn't a dictionary-like object, because *CsrfViewMiddleware* does the following (line 200):

```python
# check incoming token
request_csrf_token = request.POST.get('csrfmiddlewaretoken', '')
```

I am not 100% sure how this should be fixed. Probably not in Django directly, as the type of POST is not ambiguous, and does have a ".get" method. Maybe django-rest-framework could do the following :

```python
if hasattr(request.DATA, get):
# blabla
resp = CsrfViewMiddleware().process_view(request, None, (), {})
```