Вы должны использовать unicode
вместо string
, если вы собираетесь переводить свое приложение.
Кстати, я в случае, если вы используете json из-за запроса Ajax, я предлагаю вам отправить ошибкивернитесь с HttpResponseServerError
вместо HttpResponse
:
from django.http import HttpResponse, HttpResponseServerError
response_dict = {} # contains info to response under a django view.
try:
plan.save()
response_dict.update({'plan_id': plan.id})
except IntegrityError, e: #contains my own custom exception raising with custom messages.
return HttpResponseServerError(unicode(e))
return HttpResponse(json.dumps(response_dict), mimetype="application/json")
и затем обработайте ошибки в вашей процедуре Ajax.Если хотите, я могу опубликовать пример кода.