Django Admin Error: pop-up entry form

88 views
Skip to first unread message

Derek

unread,
Nov 19, 2013, 1:42:25 PM11/19/13
to django-users
Hi

I am using Django 1.5.5.  This error happens while running the dev server.  If I click on the "+" button so I can use the pop-up form to add a new entry to a drop-down list (i.e. FK to another model), I get the following error trace when trying to save that form.

File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  372.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  202.             return view(request, *args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
  223.                 return func(*args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in add_view
  1010.                 return self.response_add(request, new_object)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in response_add
  833.                 (escape(pk_value), escapejs(obj)))
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/functional.py" in wrapper
  196.             return func(*args, **kwargs)
File "/home/derek/.virtualenvs/s2s/local/lib/python2.7/site-packages/django/utils/html.py" in escapejs
  64.     return mark_safe(force_text(value).translate(_js_escapes))

Exception Type: TypeError at /admin/core/item/add/
Exception Value: expected a character buffer object


You can see there are no links to my code, so I am not sure what needs to change or be changed.  Is it Django code itself that is faulty?

Thanks
Derek

Derek

unread,
Nov 20, 2013, 10:17:50 AM11/20/13
to django...@googlegroups.com
Solved.  You need to add "u" to the unicode representation of your model's record.  As in:

    def __unicode__(self):
        return u'%s' % self.fieldname

This "error" does not show up in the normal admin page for the model, only when its accessed via the pop-up route.
Reply all
Reply to author
Forward
0 new messages