It is my mistake. After changing the class members, I forget to change
the __unicode__ method...
Thank you very much.
On May 30, 8:28 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sun, May 30, 2010 at 5:21 AM, Karl Lam <karl.v....@gmail.com> wrote:
> > Class A and class B were setup using syncdb. Class B has a FK of class
> > A.
>
> > First I login to the admin site to add a record of Class A. Then add a
> > record of Class B by choosing the only record of Class A as FK. Error
> > occurs after clicking "save" button. Is this a bug? or my setting is
> > wrong?
>
> > [snip]
>
> TypeError at /admin/inventory/room/add/
>
>
>
>
>
> > coercing to Unicode: need string or buffer, long found
>
> > Request Method: POST
> > Request URL: http://localhost:8888/admin/inventory/room/add/
> > Django Version: 1.2.1
> > Exception Type: TypeError
> > Exception Value:
>
> > [snip]
> > File "/usr/lib/python2.4/site-packages/django/contrib/admin/
> > options.py" in add_view
> > 800. self.log_addition(request, new_object)
> > File "/usr/lib/python2.4/site-packages/django/contrib/admin/
> > options.py" in log_addition
> > 428. object_repr = force_unicode(object),
> > File "/usr/lib/python2.4/site-packages/django/utils/encoding.py" in
> > force_unicode
> > 66. s = unicode(s)
>
> > Exception Type: TypeError at /admin/inventory/room/add/
> > Exception Value: coercing to Unicode: need string or buffer, long
> > found
>
> The admin is trying to add a log message noting the creation of the new B
> object. However when it attempts to get the unicode representation of that
> object for the log message, something other than unicode is returned. So you
> need to correct the __unicode__ method of B to return unicode (or a string
> or buffer, which could be coerced to unicode). Anything else makes Python
> raise this error.
>
> Karen
> --http://tracey.org/kmt/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment