Django

Code

Ticket #3910 (closed: duplicate)

Opened 1 year ago

Last modified 10 months ago

DataError (Data too long for column) in admin caused by html entities overflowing db field size

Reported by: miguel.carboni@gmail.com Assigned to: nobody
Milestone: Component: Admin interface
Version: 0.96 Keywords: admin, DataError
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by mtredinnick)

Hi! First of all, django is great. I have found the following Model:

class Story(models.Model):
	autor = models.CharField(maxlength=50)
	titulo = models.CharField(maxlength=100)
	texto = models.CharField(maxlength=200)

	def __str__(self):
		return self.titulo

	class Admin:
		list_filter = ['autor']
		list_display = ['titulo', 'autor' ]

The model is trivial, it's not the actual. The problem I found is that if I type í or á in the "titulo" textfield within the admin and save I got the following screen:

DataError at /admin/polls/story/2/
(1406, "Data too long for column 'message' at row 1")
Request Method: POST 
Request URL: http://localhost:8000/admin/polls/story/2/ 
Exception Type: DataError 
Exception Value: (1406, "Data too long for column 'message' at row 1") 
Exception Location: c:\python25\lib\site-packages\MySQL_python-1.2.2-py2.5-win32.egg\MySQLdb\connections.py in defaulterrorhandler, line 35 

It depends on the size of the "titulo", I guess the problem is that when it serialize "í" it turns into "í" then thes size of the verchar gets bigger than the original.

Regards! Miguel S. Carboni //developer

Attachments

Change History

04/21/07 08:13:45 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • component changed from Database wrapper to Admin interface.
  • needs_tests changed.
  • summary changed from Problems with admin and spanish stresses to DataError (Data too long for column) in admin caused by html entities overflowing db field size.
  • keywords set to admin, DataError.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.

Formatted model:

class Story(models.Model):
	autor = models.CharField(maxlength=50)
	titulo = models.CharField(maxlength=100)
	texto = models.CharField(maxlength=200)

	def str(self):
		return self.titulo

	class Admin:
		list_filter = autor
		list_display = ['titulo', 'autor' ]

04/21/07 08:17:25 changed by mtredinnick

  • description changed.

Fixed summary formatting.

09/16/07 13:52:56 changed by ubernostrum

  • status changed from new to closed.
  • resolution set to worksforme.

I suspect that either the Unicode merge fixed this, or your database and Django aren't thinking in the same charset. Please re-open if you can still reproduce on current trunk.

09/16/07 14:32:44 changed by ubernostrum

  • status changed from closed to reopened.
  • resolution deleted.

09/16/07 14:33:12 changed by ubernostrum

  • status changed from reopened to closed.
  • resolution set to duplicate.

Re-closing as a duplicate of #4336.


Add/Change #3910 (DataError (Data too long for column) in admin caused by html entities overflowing db field size)




Change Properties
Action