5

I have a DateField in django whose default value is set to timezone.now

How can I get the week of the day. I mean the day is either sunday or monday or other ??

varad
  • 6,429
  • 15
  • 56
  • 105

1 Answers1

8

A Django DateField is

represented in Python by a datetime.date instance

So in Python code you can use date.weekday() or date.isoweekday() on it.

In a template you should use the date filter, e.g.

Today is {{ date_variable|date:"l" }}
Chris
  • 112,704
  • 77
  • 249
  • 231