﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20856	Error with admin popups: expected a character buffer object	heppner.mark@…	nobody	"Using Django 1.5 and Python 2.6/2.7, I keep getting an error when using popups in the admin interface. See the example models below. When adding a model having a ForeignKey, the ForeignKey model can be added through a popup. I get the error (traceback below) of 'expected a character buffer overflow'. This only occurs with popups. Adding the ForeignKey separately works as expected. I've seen [http://lduros.net/posts/pythondjango-issue-admin-inlines/ other] [http://stackoverflow.com/questions/15162673/expected-a-character-buffer-object reports] of this error, but no solid explanation. The user from that StackOverflow question reports downgrading to Django 1.4 and the errors disappear.

{{{
class OrgUnit(models.Model):
    api_id = models.IntegerField()
    name = models.CharField()

    def __unicode__(self):
        return '%s' % self.name

class Module(models.Model):
    org_unit = models.ForeignKey(OrgUnit)
    api_id = models.IntegerField()
    name = models.CharField(max_length=255, blank=True)

    def __unicode__(self):
        return '%s (%s)' % (self.name, self.api_id)
}}}



{{{
ERROR Internal Server Error: /distance/admin/pilot_api/orgunit/add/
Traceback (most recent call last):
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/core/handlers/base.py"", line 115, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/contrib/admin/options.py"", line 372, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/utils/decorators.py"", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/views/decorators/cache.py"", line 89, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/contrib/admin/sites.py"", line 202, in inner
    return view(request, *args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/utils/decorators.py"", line 25, in _wrapper
    return bound_func(*args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/utils/decorators.py"", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/utils/decorators.py"", line 21, in bound_func
    return func(self, *args2, **kwargs2)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/db/transaction.py"", line 223, in inner
    return func(*args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/contrib/admin/options.py"", line 1010, in add_view
    return self.response_add(request, new_object)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/contrib/admin/options.py"", line 833, in response_add
    (escape(pk_value), escapejs(obj)))
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/utils/functional.py"", line 194, in wrapper
    return func(*args, **kwargs)
  File ""/usr/local/www/django/distance/lib/python2.7/site-packages/django/utils/html.py"", line 65, in escapejs
    return mark_safe(force_text(value).translate(_js_escapes))
TypeError: expected a character buffer object
}}}"	Bug	closed	contrib.admin	1.6	Normal	invalid	admin, str, character, inline, popup	Natim87	Unreviewed	0	0	0	0	0	0
