CSV 文字列を django のモデルにインポートしようとしていますが、スローされ続けます
'ascii' codec can't encode character u'\xe9' in position 29: ordinal not in range(128)
これが私の現在のビューコードです。
def saveLoot(request):
if 'q' in request.POST:
scsv = request.POST['q']
f = StringIO.StringIO(scsv)
reader = csv.reader(f, delimiter=',')
for row in reader:
user = UserProfile.objects.get(character=row[3])
loot = Loot(loot_id=row[0], item_name=row[1], source=row[2], winner=user, loot_type=row[4], lockout_tier=row[5], time=row[6], date=row[7])
loot.save()
message = "I like pie, it's good, and guess what. I've saved that for you."
else:
message = 'Fill the damn box in will you.'
return HttpResponse(message)
UserProfile モデルからユーザーを取得しようとしているところに、アクセント付きの文字が正しくエンコードされず、このエラーが強制的に発生するようです。
これはおそらく本当に基本的なものであり、デフォルトのエンコーディングを設定しようとしました.pythonを最後に見てからしばらく経ちました(ほぼ12か月).