from django.db import models
class Song(models.Model):
name = models.CharField(max_length = 50, unique = True)
lyricBy = models.CharField(max_length = 10, null = True, blank =
True)
coSinger = models.CharField(max_length = 10, null = True, blank =
True)
def __str__(self):
return self.name
class Album(models.Model):
name = models.CharField(max_length = 50, unique = True)
releaseDate = models.DateField(u'release date')
songs = models.ManyToManyField(Song)
def __str__(self):
return self.name
====================
This is my models (django 1.0)
I've used interactive shell add a new Album and at some songs to that
Album, It's ok.
When I mark Album.songs as comment. The admin page for add one Album
is all right.
But with the manytomany songs, I got this:
====================
TemplateSyntaxError at /admin/xjay/album/1/
Caught an exception while rendering: 'cp932' codec can't encode
character u'\u9f99' in position 0: illegal multibyte sequence
Original Traceback (most recent call last):
File "c:\python25\Lib\site-packages\django\template\debug.py", line
71, in render_node
result = node.render(context)
File "c:\python25\Lib\site-packages\django\template\debug.py", line
87, in render
output = force_unicode(self.filter_expression.resolve(context))
File "c:\python25\Lib\site-packages\django\utils\encoding.py", line
49, in force_unicode
s = unicode(s)
File "c:\python25\Lib\site-packages\django\forms\forms.py", line
326, in __unicode__
return self.as_widget()
File "c:\python25\Lib\site-packages\django\forms\forms.py", line
358, in as_widget
return widget.render(name, data, attrs=attrs)
File "c:\python25\Lib\site-packages\django\contrib\admin
\widgets.py", line 224, in render
output = [self.widget.render(name, value, *args, **kwargs)]
File "c:\python25\Lib\site-packages\django\forms\widgets.py", line
415, in render
options = self.render_options(choices, value)
File "c:\python25\Lib\site-packages\django\forms\widgets.py", line
376, in render_options
for option_value, option_label in chain(self.choices, choices):
File "c:\python25\Lib\site-packages\django\forms\models.py", line
569, in __iter__
yield self.choice(obj)
File "c:\python25\Lib\site-packages\django\forms\models.py", line
582, in choice
return (key, self.field.label_from_instance(obj))
File "c:\python25\Lib\site-packages\django\forms\models.py", line
625, in label_from_instance
return smart_unicode(obj)
File "c:\python25\Lib\site-packages\django\utils\encoding.py", line
35, in smart_unicode
return force_unicode(s, encoding, strings_only, errors)
File "c:\python25\Lib\site-packages\django\utils\encoding.py", line
52, in force_unicode
s = unicode(str(s), encoding, errors)
UnicodeEncodeError: 'cp932' codec can't encode character u'\u9f99' in
position 0: illegal multibyte sequence
===========================
Any idea?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---