Django

Code

Ticket #4286 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

unicode error in "added" confirmation error

Reported by: thomas.rabaix@gmail.com Assigned to: adrian
Milestone: Component: Admin interface
Version: SVN Keywords: unicode-branch
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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:

Attachments

Change History

05/12/07 22:33:24 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

is this the standard admin or the newforms-admin branch?

05/13/07 04:39:48 changed by Thomas Rabaix <thomas.rabaix@gmail.com>

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')
            }),
        )

05/13/07 04:54:01 changed by mtredinnick

  • keywords set to unicode-branch.
  • stage changed from Unreviewed to 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.

07/04/07 07:11:05 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5609]) Merged Unicode branch into trunk (r4952:5608). This should be fully backwards compatible for all practical purposes.

Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702


Add/Change #4286 (unicode error in "added" confirmation error)




Change Properties
Action