On Fri, Oct 29, 2010 at 6:30 PM, Jumpfroggy <rocketmonk...@gmail.com> wrote: > Hi all, > > I've been working in django for a while now, but am still wrapping my > head around the more complex queryset features. > > I have something like this: > > class Foo: > name = CharField() > bars = ForeignKey(Bar) > widgets = ForeignKey(Widget) > > I can do this: > > Foo.objects.extra(select={ > 'num_bars': 'SELECT COUNT(*) FROM app_bar WHERE app_bar.foo_id = > app_foo.id', > 'num_widgets': 'SELECT COUNT(*) FROM app_widget WHERE > app_widget.foo_id = app_foo.id', > }) >
Colour me confused - in your model definition, you define Foo as having a foreign key to Widget, but then your query infers that Widget in fact has a foreign key to Foo. Can you clarify? Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.