Opened 8 months ago

Last modified 5 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: no
Easy pickings: no UI/UX: no

Description

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 (3)

comment:1 Changed 8 months ago by Lefteris Nikoltsios

Has patch: set

comment:2 Changed 8 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 5 months ago by Lefteris Nikoltsios

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