Re: [Django] #10523: Changing object with long __repr__ causes error

7 views
Skip to first unread message

Django

unread,
Sep 29, 2011, 7:08:35 AM9/29/11
to django-...@googlegroups.com
#10523: Changing object with long __repr__ causes error
-------------------------------+------------------------------------
Reporter: bromer | Owner: nobody
Type: Bug | Status: reopened
Component: contrib.admin | Version: 1.2-beta
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by julien):

* ui_ux: => 0
* easy: => 0


Comment:

Most likely the issue here is when `__repr__()` returns a unicode, which
isn't properly cut down to 200 characters by simply using `[:200]`.

--
Ticket URL: <https://code.djangoproject.com/ticket/10523#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 30, 2011, 12:58:00 AM9/30/11
to django-...@googlegroups.com
#10523: Changing object with long __repr__ causes error
-------------------------------+------------------------------------
Reporter: bromer | Owner: nobody
Type: Bug | Status: reopened
Component: contrib.admin | Version: 1.2-beta
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by julien):

Like others in this thread, I can't seem to be able to reproduce this
problem. The attached patch passes for me on Python with Sqlite. Perhaps
this would need to be tested on other backends.

--
Ticket URL: <https://code.djangoproject.com/ticket/10523#comment:12>

Django

unread,
Oct 10, 2011, 10:53:50 AM10/10/11
to django-...@googlegroups.com
#10523: Changing object with long __repr__ causes error
-------------------------------+-------------------------------------
Reporter: bromer | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.2-beta
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------
Changes (by ramiro):

* status: reopened => closed
* resolution: => needsinfo


Comment:

I can run Julien's test case against PostgreSQL and MySQL without seeing
the issue. Please provide a complete test case or field value example.

--
Ticket URL: <https://code.djangoproject.com/ticket/10523#comment:13>

Django

unread,
Apr 24, 2014, 9:10:12 AM4/24/14
to django-...@googlegroups.com
#10523: Changing object with long __repr__ causes error
-------------------------------+-------------------------------------
Reporter: bromer | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.2-beta
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by hodzanassredin@…):

Can reproduce this bug: object.description = "RT @NPancheewa: "B.A.P
ถึง....อย่างปลอดภัยแล้วค่ะ" กูรอประโยคนี้ทุกครั้งที่มีการเดินทาง #비에이피
"
description = models.TextField()
def __unicode__(self):
return self.description

When I'm trying to remove it shows:
value too long for type character varying(200)

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/admin/pins/pin/342/delete/

Django Version: 1.6.2
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.gis',
'leaflet',
'djgeojson',
'storages',
'social.apps.django_app.default',
'django_extensions',
'endless_pagination',
'haystack',
'imagekit',
'auth',
'pins')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request,
*callback_args, **callback_kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/contrib/admin/options.py" in wrapper
432. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/contrib/admin/sites.py" in inner
198. return view(request, *args, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/utils/decorators.py" in _wrapper
29. return bound_func(*args, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/utils/decorators.py" in bound_func
25. return func(self, *args2, **kwargs2)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/transaction.py" in inner
339. return func(*args, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/contrib/admin/options.py" in delete_view
1463. self.log_deletion(request, obj, obj_display)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/contrib/admin/options.py" in log_deletion
632. action_flag=DELETION
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/contrib/admin/models.py" in log_action
20. e.save()
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/base.py" in save
545. force_update=force_update,
update_fields=update_fields)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/base.py" in save_base
573. updated = self._save_table(raw, cls, force_insert,
force_update, using, update_fields)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/base.py" in _save_table
654. result = self._do_insert(cls._base_manager, using,
fields, update_pk, raw)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/base.py" in _do_insert
687. using=using, raw=raw)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/manager.py" in _insert
232. return insert_query(self.model, objs, fields, **kwargs)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/query.py" in insert_query
1511. return query.get_compiler(using=using).execute_sql(return_id)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/models/sql/compiler.py" in execute_sql
899. cursor.execute(sql, params)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql,
params)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/hodza/projects/pinstream/venv/local/lib/python2.7/site-
packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)

Exception Type: DataError at /admin/pins/pin/342/delete/
Exception Value: value too long for type character varying(200)

--
Ticket URL: <https://code.djangoproject.com/ticket/10523#comment:14>

Django

unread,
Apr 24, 2014, 7:39:19 PM4/24/14
to django-...@googlegroups.com
#10523: Changing object with long __repr__ causes error
-------------------------------+-------------------------------------
Reporter: bromer | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.2-beta
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-------------------------------------

Comment (by shai):

@hodzanassredin: I suspect you're running into #22305 -- please check the
character-set of your database.

--
Ticket URL: <https://code.djangoproject.com/ticket/10523#comment:15>

Reply all
Reply to author
Forward
0 new messages