On Sat, Oct 11, 2008 at 7:52 AM, J <[EMAIL PROTECTED]> wrote: > > Hi all, > > I've got a couple of related models that I want to use together in a > queryset, which I will be passing to a the generic view > "date_based.archive_index". This generic view requires a "date_field" > argument specifying "the name of the field that the date-based archive > [view] should use to determine the objects on the page". > ( > http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-index > ) > > When I do thisk, I'm getting an error of FieldDoesNotExist ... PostI18N > has no field named 'post__date' > > I'm creating my queryset like this: > return date_based.archive_index( > request, > queryset = > > PostI18N.objects.filter(lang=request.LANGUAGE_CODE).order_by('post__date').select_related(), > date_field = 'post__date', > template_name = "posts/posts_by_tag_date.html", > template_object_name = "latest", > extra_context = xcontextdict > ) > > > The way I've got it set up in the models is: > > ###### > # The parent of all the posts, > # only one item per post in here > ###### > class Post(models.Model): > referencetitle = models.CharField(max_length=30) > date = models.DateTimeField('Date') > > ###### > # language content for each post > # there will be two items per post in here, one for each language > ###### > class PostI18N(models.Model): > post = models.ForeignKey(Post) > slug = models.SlugField( > 'Slug', > help_text='Automatically built from the title.' > ) > title = models.CharField('Title', max_length=30) > body = models.TextField('Body Text') > lang = models.CharField(max_length = 5, choices = settings.LANGUAGES) > > You posted the same question in a different thread less than 16 hours ago. Please realize that everyone who answers questions on this list volunteers their time to do so, so questions may not be answered immediately. Increasing the traffic on an already high-traffic list by duplicating questions is not polite.
I have not had time to investigate your issue in any great detail. What I can say is the date-based generic view code requires that the 'date_field' be an actual field on the model of the queryset, not a field one model removed via a foreign key. So given the models you have, you would have to be handing the generic view code a queryset that references Post objects, not PostI18N, so you can specify 'date' as the 'date_field'. Then perhaps you can figure out how to access/display information from the related Post18N object with the correct language in your generic view template, though I haven't given any thought to the specifics of that. Other approaches that occur to me which again I have not thought through in any detail: 1 - You could recast your models to avoid the problem. 2 - You could write your own view instead of using generic views. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---