2👍
✅
One way to go about this would be to (1) declare a proxy model for Sale
(2) add a custom ModelAdmin
for this proxy and (3) limit the queryset
of this custom admin to return the sales from last week alone. Something like this:
# models.py
class LastWeekSales(Sale):
class Meta:
proxy = True
verbose_name_plural = "Sales from last week"
# admin.py
class ProxySaleAdmin(SaleAdmin):
def queryset(self, request):
return self.model.objects.filter(**conditions)
admin.site.register(LastWeekSales, ProxySaleAdmin)
This way you will see a new item Sales from last week
in your admin page that lists only the last week’s sales.
Source:stackexchange.com