0

error:

UnicodeDecodeError at /admin/tree/personrol/add/
'ascii' codec can't decode byte 0xd8 in position 1: ordinal not in range(128)

in model:

from django.db import models
class Person(models.Model):
 class Meta:
 verbose_name = u'فرد'
 verbose_name_plural = u'افراد'
 name = models.CharField(max_length=100, verbose_name=u'نام فرد')
 def `__unicode__`(self):
 return self.name
class Rol(models.Model):
 class Meta:
 verbose_name = u'نقش'
 verbose_name_plural = u'نقش ها'
 name = models.CharField(max_length=100, verbose_name=u'نام نقش')
 def `__unicode__`(self):
 return self.name
class PersonRol(models.Model):
 class Meta:
 verbose_name = u'نقش فرد'
 verbose_name_plural = u'نقش افراد'
 person = models.ForeignKey('Person', related_name='person_roles', verbose_name=u'فرد')
 rol = models.ForeignKey('Rol', related_name='person_roles', verbose_name=u'نقش')
 def `__unicode__`(self):
 return '(%s , %s)' % (self.person, self.rol)
Sнаđошƒаӽ
17.9k13 gold badges78 silver badges95 bronze badges
asked Jul 3, 2014 at 7:13
2
  • Please post the full traceback. Commented Jul 3, 2014 at 7:15
  • You also dont show which model or data you are saving. Commented Jul 3, 2014 at 7:21

1 Answer 1

3

Try

return u'(%s , %s)' % (self.person, self.rol)
answered Jul 3, 2014 at 7:31
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.