On Wed, 2006-05-17 at 00:07 -0700, olive wrote: > Hello, > > First of all, my model: > > class Application(models.Model): > name = > models.CharField(_('name'),maxlength=200,unique=True) > > class Screenshot(models.Model): > application = > models.ForeignKey(Application,edit_inline=True,num_in_admin=5) > image = > models.ImageField(_('image'),upload_to="screenshots/",height_field="height",width_field="width") > caption = > models.CharField(_('caption'),maxlength=200,core=True) > height = > models.IntegerField(_('height'),blank=True,null=True,editable=False) > width = > models.IntegerField(_('width'),blank=True,null=True,editable=False) > > This: > context["app"] = > Application.objects.extra(where=['application_screenshot.application_id > = application_application.id']).distinct()
You will need to pass in a "tables" parameter here as well (tables = ['application_screenshot']), since a query on the Application object will not normally include the application_screenshot table. As a guide for the future, to debug things like this, run the failing command at the python prompt and (either before or afterwards), >>> from django.db import connection >>> connection.queries[-1]['sql'] will show you the last SQL command that you tried to execute. In this case, I suspect you will see a query that tries to use a table in the where-clause that is not in the from-clause. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---