I have never used request.read() or tried decoding the request, and I had no idea that request even had an encoding attribute. You stated that you had the exact same code working elsewhere. Is there some difference in the settings file? Some difference in the environment you are using?
When working with JSON, I use the Django Rest Framework to handle the details and just use request.POST and request.GET without worrying about other details. http://www.django-rest-framework.org/ From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Flávio Cardoso Sent: Wednesday, January 4, 2017 2:06 PM To: Django users Subject: Re: request.read() is empty in POST Childish? Ok, so I'm stuck, my project is stopped, nobody, no one, even YOU, can give me a hand. I spent days researching and debugging trying to solve the problem. I've been waiting for days for anything and nothing, nobody, including YOU told nothing to help me. If the platform - AND THE COMUNITY - can't give help nor results, I'll jump to another, simply that. The documentation is also poor. And you're donating your own time to what? Complain? Did you give me some help? No! So, if you're feeling bad with it, sorry, but I have to give value to my clients, not lose my time with children complaining because I gave up with a product that can't attend me. Wont you point a solution instead of being a crying baby? Em quarta-feira, 4 de janeiro de 2017 13:13:43 UTC-2, Avraham Serour escreveu: That's an incredibly childish response and I hope future people trying to learn python or django don't give up upon a roadblock, any future people reading this don't ever feel that you are helpless, the community has many resources to help including this mailing list. Sometimes it is difficult to express yourself in a foreign language, I always suggest to join local mailing list and contact people in your own mother tongue. Sometimes it is difficult to formulate a clear question in writing, specially in something one is not familiar with, I suggest looking for local meetups and talk personally about your bug. There are also some mentoring programs in some local communities, be sure to ask on local mailing lists for those Time is money, and it is obvious that it takes time to learn anything, take into consideration that everyone here is donating their own time. On Wed, Jan 4, 2017 at 3:22 PM, Flávio Cardoso <flavio....@gmail.com<javascript:>> wrote: I work with ASP.Net since version 1.1. I've never been with a stuck project. I'm trying to directly read the request because it is application/json, so Django doesn't delivery the data via request.GET nor .POST. And I got an exception on request.body: raise RawPostDataException("You cannot access body after reading from request's data stream") So, nevermind, you know, time is money. I was trying to learn new stuff, but I'm having many problems. Thank you. Em quarta-feira, 4 de janeiro de 2017 02:26:54 UTC-2, Vijay Khemlani escreveu: Yeah, because hitting a roadblock only happens in Django Why are you trying to read the request directly? django parses it in request.body, request.GET, request.POST, request.FILES, etc https://docs.djangoproject.com/en/1.10/ref/request-response/ On 1/4/17, Flávio Cardoso <flavio....@gmail.com<mailto:flavio....@gmail.com>> wrote: > Wow, that's sad.... :( > > I'll port it to C# > > > > Em sexta-feira, 30 de dezembro de 2016 19:52:49 UTC-2, Flávio Cardoso > escreveu: > >> Hello! I'm getting crazy, PLEASE someone, give me some light!!! >> >> I'm using Django 1.10.4, Python 3.5 on Windows using Visual Studio >> Community 2015. >> >> I have some class-based views to response some json. >> >> from django.views.generic import View >> from json import loads >> from bson.json_util import dumps >> from django.http import HttpResponse, HttpRequest >> >> class Topicos(View): >> def post(self, request): >> req = request.read().decode(self.request.encoding) >> >> Have the following setting on urls.py: >> >> url(r'^api/Topicos', Topicos.Topicos.as_view(), name='Topicos'), >> >> The request.read() is empty, the request is: >> >> POST /api/Topicos HTTP/1.1 >> Host: localhost:55020 >> Connection: keep-alive >> Content-Length: 93 >> Accept: application/json, text/plain, */* >> Origin: http://localhost:55020 >> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 >> (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36 >> X-CSRFToken: >> VRiCt3Lz1EIdKGWt3lknpcgdFpD8XbrwSxdPT4P9dd1tbrGYmgE8uHdEIH2dzP5h >> Content-Type: application/json;charset=UTF-8 >> Referer: http://localhost:55020/ >> Accept-Encoding: gzip, deflate, br >> Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4 >> Cookie: >> csrftoken=VRiCt3Lz1EIdKGWt3lknpcgdFpD8XbrwSxdPT4P9dd1tbrGYmgE8uHdEIH2dzP5h >> >> {"titulo":"Título 1","mensagem":"mensagem","email":"fla...@email.test >> .br<mailto:fla...@email.test%20%0b%3e%3e%20.br>","usuario":"Flávio"} >> >> >> I really don't know what else I can do. I have the same code (except na >> class name) running correctly to another posts. >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to > django-users...@googlegroups.com<mailto:django-users...@googlegroups.com>. > To post to this group, send email to > django...@googlegroups.com<mailto:django...@googlegroups.com>. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/1da72b67-1eb4-4dde-9e13-b3faa8d7c0c0%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com<javascript:>. To post to this group, send email to django...@googlegroups.com<javascript:>. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5e883f24-bea9-4ffe-b183-741ea919fefe%40googlegroups.com<https://groups.google.com/d/msgid/django-users/5e883f24-bea9-4ffe-b183-741ea919fefe%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com<mailto:django-users@googlegroups.com>. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6e850f3-89e5-4347-afe4-00b32a2a198e%40googlegroups.com<https://groups.google.com/d/msgid/django-users/f6e850f3-89e5-4347-afe4-00b32a2a198e%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/756cd4b998534327bef57265875cdfa6%40ISS1.ISS.LOCAL. For more options, visit https://groups.google.com/d/optout.