[Django] #28048: Generic date views don't work with related fields as date_field

7 views
Skip to first unread message

Django

unread,
Apr 7, 2017, 5:53:27 AM4/7/17
to django-...@googlegroups.com
#28048: Generic date views don't work with related fields as date_field
-------------------------------------+-------------------------------------
Reporter: Lefteris | Owner: Lefteris Nikoltsios
Nikoltsios |
Type: | Status: assigned
Uncategorized |
Component: Generic | Version: 1.11
views |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/28048>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 7, 2017, 6:02:26 AM4/7/17
to django-...@googlegroups.com
#28048: Generic date views don't work with related fields as date_field
-------------------------------------+-------------------------------------
Reporter: Lefteris Nikoltsios | Owner: Lefteris
| Nikoltsios
Type: Uncategorized | Status: assigned
Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Lefteris Nikoltsios):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8307 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:1>

Django

unread,
Apr 12, 2017, 12:26:29 PM4/12/17
to django-...@googlegroups.com
#28048: Allow generic date views to use related fields as date_field
-------------------------------------+-------------------------------------

Reporter: Lefteris Nikoltsios | Owner: Lefteris
| Nikoltsios
Type: New feature | Status: assigned

Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* needs_better_patch: 0 => 1
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:2>

Django

unread,
Jun 15, 2017, 7:41:16 PM6/15/17
to django-...@googlegroups.com
#28048: Allow generic date views to use related fields as date_field
-------------------------------------+-------------------------------------

Reporter: Lefteris Nikoltsios | Owner: Lefteris
| Nikoltsios
Type: New feature | Status: assigned
Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Lefteris Nikoltsios):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:3>

Django

unread,
Feb 16, 2018, 4:43:47 AM2/16/18
to django-...@googlegroups.com
#28048: Allow generic date views to use related fields as date_field
-------------------------------------+-------------------------------------

Reporter: Lefteris Nikoltsios | Owner: Lefteris
| Nikoltsios
Type: New feature | Status: assigned
Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:4>

Django

unread,
Jun 24, 2021, 4:26:54 AM6/24/21
to django-...@googlegroups.com
#28048: Allow generic date views to use related fields as date_field
-------------------------------------+-------------------------------------

Reporter: Lefteris Nikoltsios | Owner: Lefteris
| Nikoltsios
Type: New feature | Status: assigned
Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jaap Roes):

* cc: Jaap Roes (added)


Comment:

I created issue #32846 which was marked as a duplicate. Looking at the
patch provided for this ticket is seems that the most difficult part is
the lack of an "official" way of resolving "field paths" like
`blog__pub_date` to fields. Django admin provides some utility methods,
but since it is a contrib app it cannot be used in other "core" Django
code.

Is there a separate ticket that tracks this? (I couldn't find one.) The
addition of a canonical way to resolve field paths could also be helpful
for 3rd party apps, for example django-filter has it's own implementation:
https://github.com/carltongibson/django-
filter/blob/f507201addfb7f105e722573f3ced4b4a9870526/django_filters/utils.py#L143,
and I'm certain there are others.

--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:5>

Django

unread,
Mar 21, 2023, 5:20:38 AM3/21/23
to django-...@googlegroups.com
#28048: Allow generic date views to use related fields as date_field
-------------------------------------+------------------------------------
Reporter: Lefteris Nikoltsios | Owner: (none)
Type: New feature | Status: new

Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: Lefteris Nikoltsios => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:6>

Django

unread,
Feb 26, 2024, 1:37:23 PM2/26/24
to django-...@googlegroups.com
#28048: Allow generic date views to use related fields as date_field
-------------------------------------+------------------------------------
Reporter: Lefteris Nikoltsios | Owner: Saurabh
Type: New feature | Status: assigned
Component: Generic views | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Saurabh ):

* owner: (none) => Saurabh
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:7>
Reply all
Reply to author
Forward
0 new messages