Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8555787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:12:14+00:00 2026-06-11T15:12:14+00:00

I seem to have a unicode problem with the deal_instance_name in the Deal model.

  • 0

I seem to have a unicode problem with the deal_instance_name in the Deal model.

It says:

coercing to Unicode: need string or buffer, __proxy__ found

The exception happens on this line:

return smart_unicode(self.deal_type.deal_name) + _(u' - Set No.')  + str(self.set)

The line works if I remove smart_unicode(self.deal_type.deal_name) but why?

Back then in Django 1.1 someone had the same problem on Stackoverflow I have tried both the unicode() as well as the new smart_unicode() without any joy.

What could I be missing please?

class Deal(models.Model):
    def __init__(self, *args, **kwargs):
        super(Deal, self).__init__(*args, **kwargs)      
        self.deal_instance_name = self.__unicode__()      

    deal_type           = models.ForeignKey(DealType)
    deal_instance_name  = models.CharField(_(u'Deal Name'), max_length=100)    
    set                 = models.IntegerField(_(u'Set Number'))

    def __unicode__(self):
        return smart_unicode(self.deal_type.deal_name) + _(u' - Set No.')  + smart_unicode(self.set)

    class Meta:
        verbose_name = _(u'Deal')
        verbose_name_plural = _(u'Deals')

Dealtype:

class DealType(models.Model):    
    deal_name           = models.CharField(_(u'Deal Name'), max_length=40)
    deal_description    = models.TextField(_(u'Deal Description'),     blank=True)

    def __unicode__(self):
        return smart_unicode(self.deal_name) 

    class Meta:
        verbose_name = _(u'Deal Type')
        verbose_name_plural = _(u'Deal Types')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:12:15+00:00Added an answer on June 11, 2026 at 3:12 pm

    Actually, the smart_unicode part has nothing to do with your issue:

    from django.utils.translation import ugettext_lazy
    stuff = u'abc' + ugettext_lazy(u'efg')
    

    Would raise the exact same issue.

    That’s basically because ugettext_lazy(u'efg') will not return an unicode string, but a __proxy__, which will raise an error when you do u'abc' + ugettext_lazy(u'eg').

    You would get the exact same issue with: u'a' + 1.

    You can solve this issue using:

    from django.utils.translation import ugettext_lazy
    stuff = u'abc {0}'.format(ugettext_lazy(u'efg'))
    

    Alternatively, you could force ugettext_lazy(u'efg') into an unicode object using unicode(ugettext_lazy(u'efg')).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I seem to have a problem passing some strings on from one form to
I seem to have found a bug in jQuery UI that duplicates dragged elements
I seem to have broken validates_confirmation_of in my rails app. My model looks like
I seem to have a problem with getting MVC to fill in my custom
I seem to have the exact opposite problem than this question on stopping dock
I have a problem reading and using the content from unicode files. I am
I seem to have the all-familiar problem of correctly reading and viewing a web
I need to do a 301 redirect on a URL that may have Unicode
I have a hex-string made from a unicode string with that function: def toHex(s):
I have a problem when loading a text file with unicode content into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.