I have a very basic model:
class Link(models.Model):
title = models.CharField(max_length=250, null=False)
user = models.ForeignKey(User)
url = mo
I've read that .extra()
will be deprecated in the future. They are suggesting to instead use Func
objects. And there is one for extracting a month without using a painful Case
statement.
from django.db.models.functions import ExtractMonth
Link.objects.all().annotate(pub_date_month=ExtractMonth('pub_date'))