简体   繁体   中英

Django admin list filter date each month

ModelAdmin:

class PedidoComissaoAdmin(admin.ModelAdmin):
    list_display = ['artista', 'pedido', 'pedido_data',
                    'pedidoitem', 'valor_receber', 'data_pagamento',
                    'status', 'origem_venda']
    list_filter = ['artista__nome', 'pedido__data']
    actions = ['status_pago']

Model:

class PedidoComissao(models.Model):
    artista = models.ForeignKey(Cliente, verbose_name='Artista')
    pedido = models.ForeignKey(Pedido)
    pedidoitem = models.ForeignKey(PedidoItem, verbose_name='Arte')
    valor_receber = models.DecimalField(max_digits=11, decimal_places=2)
    data_pagamento = models.DateTimeField(auto_now_add=False)
    status = models.BooleanField(default=False)
    origem_venda = models.CharField(null=True, blank=True, max_length=30)

By this way it filters:

  • Today
  • Last 7 days
  • This month
  • This Year

How I filter the date each month?

您可以使用django-daterange-filter软件包。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM