#4796: force_unicode error
--------------------------------------+-------------------------------------
   Reporter:  [EMAIL PROTECTED]      |                Owner:  mtredinnick   
     Status:  new                     |            Component:  Core framework
    Version:                          |           Resolution:                
   Keywords:  fcgi unicode __proxy__  |                Stage:  Accepted      
  Has_patch:  0                       |           Needs_docs:  0             
Needs_tests:  0                       |   Needs_better_patch:  0             
--------------------------------------+-------------------------------------
Comment (by [EMAIL PROTECTED]):

 Nope, the patch is a no go for me:
 
 {{{
 Traceback (most recent call last):
 File "/home/fpierfed/lib/python2.4/site-
 packages/django/core/handlers/base.py" in get_response
   77. response = callback(request, *callback_args, **callback_kwargs)
 File "/home/fpierfed/lib/python2.4/site-
 packages/django/contrib/admin/sites.py" in root
   115. return self.index(request)
 File "/home/fpierfed/lib/python2.4/site-
 packages/django/contrib/admin/sites.py" in index
   273. app['models'].sort(lambda x, y: cmp(x['name'], y['name']))
 File "/home/fpierfed/lib/python2.4/site-
 packages/django/contrib/admin/sites.py" in
   273. app['models'].sort(lambda x, y: cmp(x['name'], y['name']))
 File "/home/fpierfed/lib/python2.4/site-
 packages/django/utils/functional.py" in __cmp__
   88. s = unicode(self.__func(*self.__args, **self.__kw))
 File "/home/fpierfed/lib/python2.4/site-packages/django/utils/text.py" in
   8. capfirst = lambda x: x and force_unicode(x)[0].upper() +
 force_unicode(x)[1:]
 File "/home/fpierfed/lib/python2.4/site-packages/django/utils/encoding.py"
 in force_unicode
   37. s = unicode(s)
 
   TypeError at /tips/add/
   coercing to Unicode: need string or buffer, __proxy__ found
 }}}
 
 Funny thing is that I put a
 {{{
         f = file('/tmp/pippo', 'w')
         f.write(self.verbose_name_plural)
         f.write('\n')
         f.close()
 }}}
 at the botton of
 {{{
 EasyModel.__init__()
 }}}
 but that never gets called and the file is simply not there. Maybe I am
 doing something wrong here...
 
 Anyway, here is my model
 {{{
 class Tag(models.Model):
     name = models.CharField(maxlength=255)
 
     def __str__(self):
         return(self.name)
 
 
 class Location(models.Model):
     address = models.CharField(maxlength=255, blank=True, null=True)
     city = models.CharField(maxlength=255, blank=True, null=True)
     state = models.CharField(maxlength=255, blank=True, null=True)
     country = models.CharField(maxlength=255)
     region = models.CharField(maxlength=30)
     zip_code = models.IntegerField(blank=True, null=True)
     longitude = models.FloatField(blank=True, null=True)
     latitude = models.FloatField(blank=True, null=True)
     last_seen = models.DateTimeField(default=datetime.now())
     expired = models.BooleanField()
 
     def __str__(self):
         label = ''
         if(self.address):
             label = '%s, ' %(self.address)
         if(self.city):
             label += '%s ' %(self.city)
         if(self.state):
             label += '%s ' %(self.state)
         if(self.zip_code):
             label += '%s, ' %(self.zip_code)
         if(self.country and not label):
             label = self.country
         elif(self.country):
             label = label.strip() + ', %s' %(self.country)
         return(label)
 
 
 class Tip(models.Model):
     title = models.CharField(maxlength=255)
     description = models.TextField()
 
     author = models.ForeignKey(User)
     date = models.DateTimeField(auto_now_add=True)
 
     rating = models.FloatField()
     expired = models.BooleanField()
 
     tags = models.ManyToManyField(Tag)
     location = models.ForeignKey(Location)
 
     def __str__(self):
         return(self.title)
 
 
 class Vote(models.Model):
     rating = models.IntegerField()
     comment = models.TextField()
     user = models.ForeignKey(User)
     tip = models.ForeignKey(Tip)
 
     def __str__(self):
         return(str(self.rating))
 
 
 class UserProfile(models.Model):
     user = models.ForeignKey(User, unique=True)
     picture = models.ImageField(upload_to='/tmp', blank=True, null=True)
     locations = models.ManyToManyField(Location)
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/4796#comment:14>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to