Opened 23 months ago

Last modified 12 months ago

#28048 assigned New feature

Allow generic date views to use related fields as date_field

Reported by: Lefteris Nikoltsios Owned by: Lefteris Nikoltsios
Component: Generic views Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


For example if we have some models like that:

class Blog(models.Model):
    title = models.TextField()
    pubdate = models.DateField()

class Article(models.Model):
    blog = models.ForeignKey(Blog)
    title = models.TextFIeld()
    pubdate = models.DateField()

the following view:

from django.views.generic.dates import MonthArchiveView

from .models import Article

class ArticleMonthArchiveView(MonthArchiveView):
    queryset = Article.objects.all()
    date_field = 'blog__pub_date'

will raise FieldDoesNotExist.

Change History (4)

comment:1 Changed 23 months ago by Lefteris Nikoltsios

Has patch: set

comment:2 Changed 23 months ago by Tim Graham

Patch needs improvement: set
Summary: Generic date views don't work with related fields as date_fieldAllow generic date views to use related fields as date_field
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

comment:3 Changed 21 months ago by Lefteris Nikoltsios

Patch needs improvement: unset

comment:4 Changed 12 months ago by Carlton Gibson

Patch needs improvement: set
Note: See TracTickets for help on using tickets.
Back to Top