Index: main.py
===================================================================
--- main.py	(revision 5648)
+++ main.py	(working copy)
@@ -261,21 +261,21 @@
             new_object = manipulator.save(new_data)
             pk_value = new_object._get_pk_val()
             LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), ADDITION)
-            msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': new_object}
+            msg = _(u'The %(name)s "%(obj)s" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(new_object)}
             # Here, we distinguish between different save types by checking for
             # the presence of keys in request.POST.
             if "_continue" in request.POST:
-                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
+                request.user.message_set.create(message=msg + ' ' + _(u"You may edit it again below."))
                 if "_popup" in request.POST:
                     post_url_continue += "?_popup=1"
                 return HttpResponseRedirect(post_url_continue % pk_value)
             if "_popup" in request.POST:
                 if type(pk_value) is str: # Quote if string, so JavaScript doesn't think it's a variable.
-                    pk_value = '"%s"' % pk_value.replace('"', '\\"')
-                return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
+                    pk_value = u'"%s"' % pk_value.replace('"', '\\"')
+                return HttpResponse(u'<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
                     (pk_value, force_unicode(new_object).replace('"', '\\"')))
             elif "_addanother" in request.POST:
-                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
+                request.user.message_set.create(message=msg + ' ' + (_(u"You may add another %s below.") % force_unicode(opts.verbose_name)))
                 return HttpResponseRedirect(request.path)
             else:
                 request.user.message_set.create(message=msg)
@@ -293,7 +293,7 @@
     form = oldforms.FormWrapper(manipulator, new_data, errors)
 
     c = template.RequestContext(request, {
-        'title': _('Add %s') % force_unicode(opts.verbose_name),
+        'title': _(u'Add %s') % force_unicode(opts.verbose_name),
         'form': form,
         'is_popup': '_popup' in request.REQUEST,
         'show_delete': show_delete,
@@ -309,7 +309,7 @@
     model = models.get_model(app_label, model_name)
     object_id = unquote(object_id)
     if model is None:
-        raise Http404("App %r, model %r, not found" % (app_label, model_name))
+        raise Http404(u"App %r, model %r, not found" % (app_label, model_name))
     opts = model._meta
 
     if not request.user.has_perm(app_label + '.' + opts.get_change_permission()):
@@ -321,7 +321,7 @@
     try:
         manipulator = model.ChangeManipulator(object_id)
     except model.DoesNotExist:
-        raise Http404('%s object with primary key %r does not exist' % (model_name, escape(object_id)))
+        raise Http404(u'%s object with primary key %r does not exist' % (model_name, escape(object_id)))
 
     if request.POST:
         new_data = request.POST.copy()
@@ -339,28 +339,28 @@
             # Construct the change message.
             change_message = []
             if manipulator.fields_added:
-                change_message.append(_('Added %s.') % get_text_list(manipulator.fields_added, _('and')))
+                change_message.append(_(u'Added %s.') % get_text_list(manipulator.fields_added, _('and')))
             if manipulator.fields_changed:
-                change_message.append(_('Changed %s.') % get_text_list(manipulator.fields_changed, _('and')))
+                change_message.append(_(u'Changed %s.') % get_text_list(manipulator.fields_changed, _('and')))
             if manipulator.fields_deleted:
-                change_message.append(_('Deleted %s.') % get_text_list(manipulator.fields_deleted, _('and')))
+                change_message.append(_(u'Deleted %s.') % get_text_list(manipulator.fields_deleted, _('and')))
             change_message = ' '.join(change_message)
             if not change_message:
-                change_message = _('No fields changed.')
+                change_message = _(u'No fields changed.')
             LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, force_unicode(new_object), CHANGE, change_message)
 
-            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': new_object}
+            msg = _(u'The %(name)s "%(obj)s" was changed successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(new_object)}
             if "_continue" in request.POST:
-                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
+                request.user.message_set.create(message=msg + ' ' + _(u"You may edit it again below."))
                 if '_popup' in request.REQUEST:
                     return HttpResponseRedirect(request.path + "?_popup=1")
                 else:
                     return HttpResponseRedirect(request.path)
             elif "_saveasnew" in request.POST:
-                request.user.message_set.create(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': new_object})
-                return HttpResponseRedirect("../%s/" % pk_value)
+                request.user.message_set.create(message=_(u'The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(new_object)})
+                return HttpResponseRedirect(u"../%s/" % pk_value)
             elif "_addanother" in request.POST:
-                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
+                request.user.message_set.create(message=msg + ' ' + (_(u"You may add another %s below.") % force_unicode(opts.verbose_name)))
                 return HttpResponseRedirect("../add/")
             else:
                 request.user.message_set.create(message=msg)
@@ -389,13 +389,13 @@
     for related in opts.get_followed_related_objects():
         wrt = related.opts.order_with_respect_to
         if wrt and wrt.rel and wrt.rel.to == opts:
-            func = getattr(manipulator.original_object, 'get_%s_list' %
+            func = getattr(manipulator.original_object, u'get_%s_list' %
                     related.get_accessor_name())
             orig_list = func()
             form.order_objects.extend(orig_list)
 
     c = template.RequestContext(request, {
-        'title': _('Change %s') % force_unicode(opts.verbose_name),
+        'title': _(u'Change %s') % force_unicode(opts.verbose_name),
         'form': form,
         'object_id': object_id,
         'original': manipulator.original_object,
@@ -428,7 +428,7 @@
                 pass
             else:
                 if related.opts.admin:
-                    p = '%s.%s' % (related.opts.app_label, related.opts.get_delete_permission())
+                    p = u'%s.%s' % (related.opts.app_label, related.opts.get_delete_permission())
                     if not user.has_perm(p):
                         perms_needed.add(related.opts.verbose_name)
                         # We don't care about populating deleted_objects now.
@@ -459,7 +459,7 @@
             # If there were related objects, and the user doesn't have
             # permission to delete them, add the missing perm to perms_needed.
             if related.opts.admin and has_related_objs:
-                p = '%s.%s' % (related.opts.app_label, related.opts.get_delete_permission())
+                p = u'%s.%s' % (related.opts.app_label, related.opts.get_delete_permission())
                 if not user.has_perm(p):
                     perms_needed.add(related.opts.verbose_name)
     for related in opts.get_all_related_many_to_many_objects():
@@ -480,14 +480,14 @@
                 if related.field.rel.edit_inline or not related.opts.admin:
                     # Don't display link to edit, because it either has no
                     # admin or is edited inline.
-                    nh(deleted_objects, current_depth, [_('One or more %(fieldname)s in %(name)s: %(obj)s') % \
-                        {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name), 'obj': escape(sub_obj)}, []])
+                    nh(deleted_objects, current_depth, [_(u'One or more %(fieldname)s in %(name)s: %(obj)s') % \
+                        {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name), 'obj': force_unicode(escape(sub_obj))}, []])
                 else:
                     # Display a link to the admin page.
                     nh(deleted_objects, current_depth, [
-                        (_('One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name)}) + \
+                        (_(u'One or more %(fieldname)s in %(name)s:') % {'fieldname': force_unicode(related.field.verbose_name), 'name': force_unicode(related.opts.verbose_name)}) + \
                         (u' <a href="../../../../%s/%s/%s/">%s</a>' % \
-                            (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), escape(sub_obj))), []])
+                            (related.opts.app_label, related.opts.module_name, sub_obj._get_pk_val(), force_unicode(escape(sub_obj)))), []])
         # If there were related objects, and the user doesn't have
         # permission to change them, add the missing perm to perms_needed.
         if related.opts.admin and has_related_objs:
@@ -499,7 +499,7 @@
     model = models.get_model(app_label, model_name)
     object_id = unquote(object_id)
     if model is None:
-        raise Http404("App %r, model %r, not found" % (app_label, model_name))
+        raise Http404(u"App %r, model %r, not found" % (app_label, model_name))
     opts = model._meta
     if not request.user.has_perm(app_label + '.' + opts.get_delete_permission()):
         raise PermissionDenied
@@ -517,7 +517,7 @@
         obj_display = force_unicode(obj)
         obj.delete()
         LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, object_id, obj_display, DELETION)
-        request.user.message_set.create(message=_('The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': obj_display})
+        request.user.message_set.create(message=_(u'The %(name)s "%(obj)s" was deleted successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': obj_display})
         return HttpResponseRedirect("../../")
     extra_context = {
         "title": _("Are you sure?"),
@@ -536,13 +536,13 @@
     model = models.get_model(app_label, model_name)
     object_id = unquote(object_id)
     if model is None:
-        raise Http404("App %r, model %r, not found" % (app_label, model_name))
+        raise Http404(u"App %r, model %r, not found" % (app_label, model_name))
     action_list = LogEntry.objects.filter(object_id=object_id,
         content_type__id__exact=ContentType.objects.get_for_model(model).id).select_related().order_by('action_time')
     # If no history was found, see whether this object even exists.
     obj = get_object_or_404(model, pk=object_id)
     extra_context = {
-        'title': _('Change history: %s') % obj,
+        'title': _(u'Change history: %s') % obj,
         'action_list': action_list,
         'module_name': force_unicode(capfirst(model._meta.verbose_name_plural)),
         'object': obj,
