문제

안녕하세요 (저의 못생긴 영어로 실례합니다 : P),

이 두 가지 간단한 모델을 상상해보십시오.

from django.contrib.contenttypes import generic
from django.db import models

class SomeModel(models.Model):
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField(_('object id'))
    content_object = generic.GenericForeignKey('content_type', 'object_id')

    published_at = models.DateTimeField('Publication date')


class SomeOtherModel(models.Model):
    related = generic.GenericRelation(SomeModel)

Archive_Index 일반보기를 일부 점선과 함께 사용하고 싶지만 작동하지 않습니다.

from django.views.generic.date_based import archive_index

archive_index(request, SometherModel.objects.all(), 'related__published_at')

오류는 28 행의 Archive_index에서 나옵니다 (django 1.1 사용) :

date_list = queryset.dates(date_field, 'year')[::-1]

제기 된 예외는 다음과 같습니다.

SomeOtherModel has no field named 'related__published_at'

고치는 아이디어가 있습니까?

매우 감사합니다 :)

도움이 되었습니까?

해결책

Django 소스 코드를 파기부터 일반보기 archive_index 관련 분야를 지원하는 것으로 보이지 않습니다 GenericRelation에스.

쿼리 세트 메소드 때문입니다 dates 일반적인 관계를 지원하지 않습니다. Django Bug Tracker에서 버그 / 기능 요청으로 제출하는 것을 고려하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top