0๐
โ
Ok, I solved it like this:
changed my Ajax request from GET to POST,
followed this to acquire CSRF_token,
used this parser to parse my object,
and finally changed my Python function:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def startNewVoting(request):
from querystring_parser import parser
p = parser.parse(request.POST.urlencode())
for key, track in p['tracks'].iteritems():
print track
# save to db...
๐คerrata
5๐
You can solve it by using json encoding:
encode in javascript
data: {tracks: JSON.stringify(tracks)}
decode in the view
tracks = json.loads(request.POST.get('tracks'))
This way you avoid 3rd party parser ๐
๐คmariodev
- [Django]-TypeError: unsupported operand type(s) for /: 'str' and 'str' django setting.py
- [Django]-Validation Error with Multiple File Uploads in Django via Ajax
- [Django]-How to match dictionary keys to model ids
- [Django]-Where to store api key in Django
- [Django]-Writing multiple page pdf from html template using weasy print and django
Source:stackexchange.com