Opened 16 years ago

Closed 16 years ago

#6336 closed (duplicate)

models.TextField gives an error on syncdb, if unique set to true

Reported by: Shabda Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords: models
Cc: shabda.raaj@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


models.TextField is giving errors if unique=True

from django.db import models

class Category(models.Model):
    """Category under which a page is classified. ManyToMany relationship with pages."""
    text = models.TextField(max_length = 100, unique = True)

Get this model in, and run syncdb. You will get an error like

Traceback (most recent call last):
  File "F:\djangoprojects\testme\", line 11, in ?
  File "C:\Python24\lib\site-packages\django\core\management\", line
272, in execute_manager
  File "C:\Python24\lib\site-packages\django\core\management\", line
219, in execute
  File "C:\Python24\lib\site-packages\django\core\management\", line 72,
in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python24\lib\site-packages\django\core\management\", line 86,
in execute
    output = self.handle(*args, **options)
  File "C:\Python24\lib\site-packages\django\core\management\", line 168,
 in handle
    return self.handle_noargs(**options)
  File "C:\Python24\lib\site-packages\django\core\management\commands\"
, line 74, in handle_noargs
  File "C:\Python24\lib\site-packages\django\db\backends\", line 18, in e
    return self.cursor.execute(sql, params)
  File "C:\Python24\Lib\site-packages\MySQLdb\", line 166, in execute
    self.errorhandler(self, exc, value)
  File "C:\Python24\Lib\site-packages\MySQLdb\", line 35, in defau
    raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1170, "BLOB/TEXT column 'text' used in key
specification without a key length")

Change the type to SlugField or remove the unique and try syncdb, you will get no errors.

Change History (2)

comment:1 by Shabda, 16 years ago

Cc: shabda.raaj@… added

comment:2 by Simon Greenhill <dev@…>, 16 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #2495

Note: See TracTickets for help on using tickets.
Back to Top