I just remembered that the above error occured when running on Postgresql 8.2. Sorry for the misinformation about SQLite.
Then to give it a try with SQLite, I built a fresh database with syncdb on SQLite. This time, at the same point, I get a: OperationalError: no such column: tagging_taggeditem.added This is very strange, because the column 'added' is surely there. On Feb 1, 11:39 pm, omat <o...@gezgin.com> wrote: > Hi, > > TaggedItem model is as follows: > > class TaggedItem(models.Model): > tag = models.ForeignKey(Tag, verbose_name=_('tag'), > related_name='items') > added = models.DateTimeField(auto_now_add=True) > content_type = models.ForeignKey(ContentType, verbose_name=_ > ('content type')) > object_id = models.PositiveIntegerField(_('object id'), > db_index=True) > object = generic.GenericForeignKey('content_type', 'object_id') > > And I am using sqlite on Mac OS X with django revison 9781. > > Thanks,oMat > > On Feb 1, 1:12 am, Russell Keith-Magee <freakboy3...@gmail.com> wrote: > > > On Sun, Feb 1, 2009 at 12:44 AM,omat<o...@gezgin.com> wrote: > > > > Hi all, > > > > I obtain a list of tag ids by: > > > tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max > > > ('added'))[:10] > > > > and try to use it in the following query to obtain tag objects: > > > Tag.objects.filter(id__in=tag_ids) > > > > But i get "invalid reference to FROM-clause" error: > > > > Caught an exception while rendering: invalid reference to FROM-clause > > > entry for table "tagging_taggeditem" > > > LINE 1: ...RE "tagging_tag"."id" IN (SELECT U0."tag_id", MAX > > > ("tagging_t... > > > ^ > > > HINT: Perhaps you meant to reference the table alias "u0". > > > > If I force the first query to be evaluated, using the step syntax (ie > > > [:10:1] instead of [:10]), then everthing works fine. > > > > Seems like a bug? > > > I'm not seeing this failure on SQLite, Postgres or MySQL. However, I > > was testing using my own test models, not your models - it's possible > > that the problem could be caused by the interaction of some other > > property of your model on the aggregate query. > > > Can you provide the full definition of the TaggedItem model you are > > using? It would also be helpful to know the database version and > > operating system you are using. > > > Yours, > > Russ Magee %-) --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---