TypeError: 'datetime.date' object has no attribute '__getitem__'

django, django-admin, django-models, sqlite

Solution

Your `__unicode__` methods need to return a Unicode string, not a `datetime.date` object. So you should adapt the following to return Unicode:

def __unicode__(self):
    return self.data_pedido

For example:

def __unicode__(self):
    return unicode(self.data_pedido)

Or you can format the date using a formatting method.

Problem

I use in my models.py ``` class Pedido(models.Model): data_pedido = models.DateField('Data do pedido') cliente = models.ForeignKey(Cliente) ``` but runserver and add date via admin show this message. I use sqlite3. See my project in github

Original source