#4286 closed (fixed)
unicode error in "added" confirmation error
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | unicode-branch | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I am using django with the french i18n enabled. When I add a new object from the admin I get a Unicode Error. I fixed the problem with this patch
The french message was : L'objet %(name)s "%(obj)s" a été ajouté avec succès.
Index: main.py =================================================================== --- main.py (revision 5173) +++ main.py (working copy) @@ -254,7 +254,9 @@ 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, str(new_object), ADDITION) - msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_object} + from django.utils.encoding import StrAndUnicode, smart_unicode + msg = smart_unicode(_('The %(name)s "%(obj)s" was added successfully.')) + msg = msg % {'name': opts.verbose_name, 'obj': new_object} # Here, we distinguish between different save types by checking for # the presence of keys in request.POST. if "_continue" in request.POST:
Change History (5)
comment:1 by , 18 years ago
comment:2 by , 18 years ago
It is in the standard admin.
With this model :
class Page(models.Model): title = models.CharField(verbose_name="Titre",maxlength=255) url = models.CharField(maxlength=255, unique=True) html = models.TextField(verbose_name="Contenu",blank=True) css = models.TextField(verbose_name="Style CSS",blank=True) js = models.TextField(verbose_name="Javascript", blank=True) keywords = models.TextField(blank=True) date_added = models.DateField(auto_now_add=True) date_modified = models.DateField(auto_now=True) def get_absolute_url(self): return self.url def __str__(self): return self.title + " -- " + self.url class Admin: save_on_top = True list_display = ('title','url', 'date_added', 'date_modified') list_per_page= 25 search_fields = ['title','url','html'] ordering = ['title'] fields = ( ('Page', { 'fields': ('title', 'url', 'html') }), ('Options', { 'fields' : ('css','js','keywords') }), )
comment:3 by , 18 years ago
Keywords: | unicode-branch added |
---|---|
Triage Stage: | Unreviewed → Accepted |
This has been fixed in the unicode branch in a slightly different way, although I still need to make a bunch of changes to translation markups as well (which will fix it a second time).
I'll mark this as closed once the unicode branch is complete and merged back into trunk.
comment:4 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
is this the standard admin or the newforms-admin branch?