{{{
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.
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/8307 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:1>
* needs_better_patch: 0 => 1
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:2>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:3>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:4>
* 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>
* owner: Lefteris Nikoltsios => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/28048#comment:6>