AJW
AJW

Reputation: 5863

django postgresql OperationalError: index row size xxx exceeds maximum yyy

I am trying to learn a bit of django and trying to insert some values in a database (using model forms), but this seems failing citing:

django.db.utils.OperationalError: index row size 3008 exceeds maximum 2712 for index "appname_mymodel_ggg_like"

My models are quite simple and look like so:

class myModel(TimeStampedModel):

    fff =  models.URLField(db_index=False, blank=False,primary_key=False) 
    ggg = models.TextField(db_index=False, blank=False,primary_key=False)
    mj = models.BooleanField(db_index=False, blank=False, primary_key=False,  default=False) # req field

def __unicode__(self):
    return self.fff

Does this mean that the string is long (yes it is, but not a 1MB string or anything)? This is the reason I was using text field.. but this does not seem to help.

Any hints would be appreciated..

Upvotes: 5

Views: 1631

Answers (1)

David Schumann
David Schumann

Reputation: 14793

If anyone gets here through the error message, for me it was this unresolved bug.

Basically a django TextField can be large in size, but if we make it unique as well, the uniqueness check can break.

A suggested "fix" was using the md5 hash for the uniqueness check.

Upvotes: 1

Related Questions