summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrabhu Ramachandran2011-11-26 13:23:40 +0530
committerPrabhu Ramachandran2011-11-26 13:23:40 +0530
commit9b7c400f915e83492826be272d5201abfe1779f1 (patch)
treef6af75d2899c67983bd8997f0f1b4289d9ce3e43
parent661933dc2d7351b52bfd8b599bd0f8ba700f3b4a (diff)
downloadonline_test-9b7c400f915e83492826be272d5201abfe1779f1.tar.gz
online_test-9b7c400f915e83492826be272d5201abfe1779f1.tar.bz2
online_test-9b7c400f915e83492826be272d5201abfe1779f1.zip
BUG: Encoding to ascii produces errors.
Some users seem to submit unicode characters (bah!), this changeset deals with these gracefully.
-rw-r--r--exam/management/commands/dump_user_data.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/exam/management/commands/dump_user_data.py b/exam/management/commands/dump_user_data.py
index 6e0ca2a..ec016bb 100644
--- a/exam/management/commands/dump_user_data.py
+++ b/exam/management/commands/dump_user_data.py
@@ -1,3 +1,5 @@
+import sys
+
# Django imports.
from django.core.management.base import BaseCommand
from django.template import Template, Context
@@ -81,7 +83,7 @@ def dump_user_data(unames, stdout):
data = get_user_data(user.username)
context = Context({'data': data})
result = data_template.render(context)
- stdout.write(result)
+ stdout.write(result.encode('ascii', 'xmlcharrefreplace'))
class Command(BaseCommand):
args = '<username1> ... <usernamen>'