Django 1.10 + Django Restless 0.0.10 and Empty Request

Asked

Viewed 34 times

0

I’m using Django Restless views to build some REST interfaces and in all posts the request.POST and request.params are empty.

In case I run:

print request
print request.POST

I have the following return:

<WSGIRequest: POST '/ambiente/alo/cadastrosplash/448/'>
<QueryDict: {}>

Follows the header of the method you inherit from Restless.views.Endpoint:

from restless.views import Endpoint
class CadastroSplash(Endpoint):
    def post(self, request, idCampanha, **kwargs):

In the.py url, the configuration is this way:

from django.views.decorators.csrf import ensure_csrf_cookie
from meuprojeto.meupacote.views import CadastroSplash

urlpatterns = [
    url(r'^cadastrosplash/(?P<idCampanha>\d{1,8})/$$',
         ensure_csrf_cookie(CadastroSplash.as_view())),
]

This way the "post" method is executed correctly, the value of the parameter idCampanha is filled in, but with empty request fields.

If I create a view method the request comes correctly filled, but it is something I would not like to do for the sake of standardization of methods.

Some additional information: I’m using Jango with apache2 and WSGI module. The form is a Multipart/form-date for uploading files. There is this same application running with Django 1.5 and djangorestless 0.0.9 on the same server in a separate virtualenv, this method works correctly and receives all parameters.

Thank you all for your attention

1 answer

0

I contacted the developer of djangorestless on github.

The method dispatch class restless.views.Endpoint has in the first line:

request.content_type = request.META.get('CONTENT_TYPE', 'text/plain')

This code when executed causes a Multipart/form-date form to be cleaned in Django 1.10.

Developer already reported that will fix the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.