How to get a application-formpost in django view? Get QueryDict variables.

34 views
Skip to first unread message

Fellipe Henrique

unread,
May 21, 2015, 8:29:20 AM5/21/15
to Django Users
Hello, 

I need to get one application-form-post content from one server. This server isn't mine.

They send to me this application-form-post, and in Django View I receive this:

<QueryDict: {'data[id]': ['D6adasd7065C2C0A84C96B47EA17705991B14'], 'data[status]': ['paid'], 'event': ['invoice']}>

I need to get: data['id'], data['status']  and event variables..

How I do this in django? Because I can't work with QueryDict... I try to transform in python dict, in python list, but anyone works...

Any idea for these problem?

Regards,


T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

Gergely Polonkai

unread,
May 21, 2015, 9:16:30 AM5/21/15
to django...@googlegroups.com

Assuming your QueryDict is called my_post_data, use my_post_data.get('data[id]').

--
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.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAF1jwZFv5zwKHaDAFOz06n_%2B4EiNzzFoYx9t_MfTNnEFranAWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Fellipe Henrique

unread,
May 21, 2015, 9:24:36 AM5/21/15
to Django Users
Thanks, I try that! but show me None as value...

I think, that's because the QueryDict is showed in this way:

<QueryDict: {"'data[id]': ['83A0C50B5A0A43AD8F60C1066B16A163'], 'data[status]': ['paid'], 'event': ['invoice.status_changed']": ['']}>

I think the django takes 

'data[id]': ['83A0C50B5A0A43AD8F60C1066B16A163'], 'data[status]': ['paid'], 'event': ['invoice.status_changed']

as the "key"...

:(

T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

Fellipe Henrique

unread,
May 21, 2015, 2:34:53 PM5/21/15
to Django Users
Any ideas?

I finish all my possibilities in these problem.. :( and no solution...

T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

Vijay Khemlani

unread,
May 21, 2015, 5:14:44 PM5/21/15
to django...@googlegroups.com
Maybe the brackets confuse the querydict, try calling its items method (to convert it into a list of tuples) or its dict method (to turn it into a normal python dict)

Gergely Polonkai

unread,
May 22, 2015, 1:53:47 AM5/22/15
to django...@googlegroups.com

I don't think so, maybe the post request is poorly formatted. Can you somehow catch the raw http request for analyzing?

Fellipe Henrique

unread,
May 22, 2015, 8:46:31 AM5/22/15
to Django Users
Here is the request.body:

b"'data[id]', ['83A0C50B5A0A43AD8F60C1066B16A163']&'data[status]', ['paid']&'event',['invoice.status_changed']"

I think, maybe, something is wrong in Django, because these same POST is easy to get using PHP or Rails.. in PHP I get with these:  $_POST['data']['id']

Maybe, something in django isn't implemented yet for these kind POST.

T.·.F.·.A.·.     S+F
Fellipe Henrique P. Soares

e-mail: > echo "lkrrovknFmsgor4ius" | perl -pe \ 's/(.)/chr(ord($1)-2*3)/ge'
Twitter: @fh_bash

Gergely Polonkai

unread,
May 22, 2015, 1:54:30 PM5/22/15
to django...@googlegroups.com

Actually, it is Django that handles it right. Where there are colons (,), there should be equation signs. This is not really HTTP compliant, so I'm afraid you must process the incoming data (i.e. request.body) yourself.

Reply all
Reply to author
Forward
0 new messages