0

This is my model:

class Meeting(models.Model):
start_time = models.TimeField(null=True)

def __unicode__(self):
    return u'%s' % (str(self.start_time))

When I do Meeting.objects.all()

I get

TypeError: not all arguments converted during string formatting

Hopefully this is an easy question! Thanks a lot :)

user1420563
  • 195
  • 1
  • 12

1 Answers1

0

The TimeField stores time in a python datetime instance. From the django docs:

class TimeField(auto_now=False, auto_now_add=False, **options)

A time, represented in Python by a datetime.time instance.

You should be able to print the datetime object directly to the console, but if you need to convert it to a string, you should always use python's built in time framework. Specifically, strftime()

https://docs.python.org/2/library/time.html#time.strftime

Community
  • 1
  • 1
King_llama
  • 179
  • 2
  • 2
  • 12