On my html I have script that creates form in a modal, from table. I have there text as well as file, so data is "multipart/form-data"
var modalForm = $('<form role="form" name="modalForm" action="/admin/" method="POST" enctype="multipart/form-data"></form>');
In my flask, I'm getting POST back with:
from werkzeug.datastructures import CombinedMultiDict, ImmutableMultiDict
imd = ImmutableMultiDict(request.form)
and I receive :
ImmutableMultiDict([('username', u'John'), ('email', u'john@snow.com')])
Which is weird for me - why i receive it as a immutableMultiDict, why it's not processed? but ok. Now If I would do:
for i in imd.itervalues():
print i
I would get:
John
john@snow.com
Awesome! BUT why if I ask for
imd['username']
or
imd.get('username')
I am getting with unicode string
u'John' sure, I could fix that with str(imd['username']) but I haven't seen anyone else doing so within examples on internet. What might be wrong ?
When I have tried
CombinedMultiDict((request.files, request.form))
I received:
CombinedMultiDict((ImmutableMultiDict([('avatar', )]), ImmutableMultiDict([('username', u'John'), ('email', u'John@snow.com')])))