-1
  def was_published_recently(self):
       return self.pub_date >= timezone.now() - datetime.timedelta(days=1)

In a django project i used this function but i do not know why i used this

swatty
  • 1

1 Answers1

0

This is in reference to the admin section of django.

In the admin section corresponding to models, each models has a property called list_display, which control which fields are displayed on the change list (list display of all the objects) page of the admin.

Now, if you wish to change the default sort order for was_published_recently in the list_display you can do so by setting the admin_order_field attribute.

For your reference

From the django tutorial was_published_recently.admin_order_field = 'pub_date'

Anoop
  • 505
  • 8
  • 23