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

34 ವೀಕ್ಷಣೆಗಳು
ಮೊದಲು ಓದದ ಸಂದೇಶಕ್ಕೆ ಸ್ಕಿಪ್ ಮಾಡಿ

Fellipe Henrique

ಓದದಿರುವುದು,
ಮೇ 21, 2015, 08:29:20 ಪೂರ್ವಾಹ್ನ21/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 21, 2015, 09:16:30 ಪೂರ್ವಾಹ್ನ21/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 21, 2015, 09:24:36 ಪೂರ್ವಾಹ್ನ21/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 21, 2015, 02:34:53 ಅಪರಾಹ್ನ21/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 21, 2015, 05:14:44 ಅಪರಾಹ್ನ21/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 22, 2015, 01:53:47 ಪೂರ್ವಾಹ್ನ22/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 22, 2015, 08:46:31 ಪೂರ್ವಾಹ್ನ22/5/15
ಗೆ 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

ಓದದಿರುವುದು,
ಮೇ 22, 2015, 01:54:30 ಅಪರಾಹ್ನ22/5/15
ಗೆ 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.

ಎಲ್ಲರಿಗೂ ಪ್ರತ್ಯುತ್ತರಿಸಿ
ಲೇಖಕರಿಗೆ ಪ್ರತ್ಯುತ್ತರಿಸಿ
ಫಾರ್ವರ್ಡ್ ಮಾಡಿ
0 ಹೊಸ ಸಂದೇಶಗಳು