If there's nothing I can determine here, I'll move over to submitting a ticket on the matter. Wanted to check in here first.
Using... Django 1.2 SVN revision 11653, (updated just 2 minutes ago) MySQL 5.1.31 Models: class Category(models.Model): category = models.CharField() class Question(models.Model): category = models.ForeignKey(Category) class Template(models.Model): categories = models.ManyToManyField(Category, related_name='templates') questions = models.ManyToManyField('Question', related_name='templates', limit_choices_to=Q(category__in=F ('templates__categories'))) The error popped up while I was playing with that 'limit_choices_to' option on Template.questions. The error text: Caught an exception while rendering: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`surveys_surveytemplate_categories`.`surveycategory_id`' at line 1") The logic behind the model setup is that a Template consists of Categories and Questions. Since each Question has an underlying Category of its own, I want to filter the Question list to only contain items whose own Category is found on the base Template's m2m relationship to Category. Please ask if clarification is needed.. This setup works great if I remove the usage of 'F ("templates__categories")' and just hardcode a '[1,2]' in its place. Something about using 'F' in a 'Q' in 'limit_choices_to' is not working. Any ideas on how I could snag the SQL and print it out somehow? This isn't like PHP where I can just throw down a print line anywhere in the code, even if I use an event listener attached to the query-making pipeline. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---