3

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.

enter image description here

enter image description here

See my project in github

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.