Try using django-debug-toolbar. It will show the POST and GET values.
Also, you can use request.POST.get('formID') instead, which will return None
(or the second, optional argument) if it's empty.
What is your json_response middleware doing? Could it have anything to do with
this?
What if you just print (or log debug) request.POST to the terminal output --
anything there?
Shawn
On May 31, 2010, at 9:40 AM, Brian wrote:
> Hello!
>
> I could use some help tracking down a problem here. I have a view that
> starts as follows:
>
> @login_required
> @json_response
> def save_exercise_week( request, week_id ):
> formID = request.POST['formID']
>
> But this returns a 500 error because the QueryDict is empty --
> MultiValueDictKeyError at ... "Key 'formID' not found in <QueryDict: {}
>> " In fact, according to the Django error page, there is no GET, POST,
> or FILES data.
>
> I've checked my HTML form over several times and it looks fine. In
> Firebug, it says the POST sent is:
>
> csrfmiddlewaretoken: ...
> fatPercentage: 10
> formID: formWeek4
> weekNumber: 17
> weight: 150.0
> year: 2010
>
> which is correct. So, it looks like somewhere between the sending of
> the request and the calling of the view, the POST data is lost. I am
> using an XHR request to retrieve this view, but that's working fine
> for other views in my project. I would appreciate any ideas about what
> might be causing this. I've attached more data below from the error.
> Thank you!
>
>
> CSRF_COOKIE '...'
> DOCUMENT_ROOT '...'
> GATEWAY_INTERFACE 'CGI/1.1'
> HTTP_ACCEPT 'text/html,application/xhtml+xml,application/xml;q=0.9,*/
> *;q=0.8'
> HTTP_ACCEPT_CHARSET 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
> HTTP_ACCEPT_ENCODING 'gzip,deflate'
> HTTP_ACCEPT_LANGUAGE 'en-us,en;q=0.5'
> HTTP_CONNECTION 'close'
> HTTP_COOKIE 'csrftoken=6cd4642c36c8ff19dcb0c734a2d45fb6;
> sessionid=8c8ddb6631837ba811a62c8076f7521f; logintheme=cpanel;
> cprelogin=no;
> cpsession=HVb7EJsM_GibQJqkt_Z2NvUxRp0F0VNWv1qQNRTqYwc09MfDogZU7pbsZjbGjmuf'
> HTTP_HOST '...'
> HTTP_USER_AGENT 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-
> US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10'
> PATH '/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/courier-imap/
> sbin:/usr/lib/courier-imap/bin:/usr/local/sbin:/usr/local/bin:/sbin:/
> bin:/usr/sbin:/usr/bin:/usr/X11R6/bin'
> PATH_INFO u'...'
> PATH_TRANSLATED 'redirect:/cgi-bin/gfnn.fcgi/v2/exercise/save/week/4//
> exercise/save/week/4/'
> QUERY_STRING ''
> REDIRECT_STATUS '200'
> REDIRECT_TZ 'America/Los_Angeles'
> REDIRECT_UNIQUE_ID 'TAO30K6EpiIAAFFKYocAAAKQ'
> REDIRECT_URL '...'
> REMOTE_ADDR '217.41.238.90'
> REMOTE_PORT '53799'
> REQUEST_METHOD 'GET'
> REQUEST_URI '/v2/exercise/save/week/4/'
> SCRIPT_FILENAME '.../cgi-bin/gfnn.fcgi'
> SCRIPT_NAME u''
> SERVER_ADDR '174.132.166.58'
> SERVER_ADMIN '...'
> SERVER_NAME '...'
> SERVER_PORT '80'
> SERVER_PROTOCOL 'HTTP/1.1'
> SERVER_SIGNATURE '<address>Apache mod_fcgid/2.3.5
> mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server
> at gofitnow.net Port 80</address>\n'
> SERVER_SOFTWARE 'Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1
> mod_bwlimited/1.4 FrontPage/5.0.2.2635'
> TZ 'America/Los_Angeles'
> UNIQUE_ID 'TAO30K6EpiIAAFFKYocAAAKQ'
> wsgi.errors <flup.server.fcgi_base.OutputStream object at 0x901a64c>
> wsgi.input <flup.server.fcgi_base.InputStream object at 0x9050dac>
> wsgi.multiprocess False
> wsgi.multithread True
> wsgi.run_once False
> wsgi.url_scheme 'http'
> wsgi.version (1, 0)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.