I was wondering what people thought of adding a .exists() method to querysets that would take another QuerySet, and add a "WHERE EXISTS (SELECT ...)" to the original query. It would require that the passed- in QuerySet be joinable with the original QuerySet via a ForeignKey relationship. Take the following example:
class Record (models.Model): name = models.CharField( max_length=100 ) active = models.BooleanField() class RecordValue (models.Model): record = models.ForeignKey( Record, related_name='values' ) value = models.TextField() Now suppose you want to build a search engine. Searching for Record.name='Dan' would be easy, and searching for Records with a RecordValue.value='django' is also [slightly less] easy. But the latter requires using a RecordValue queryset, and extracting the records from it. So I thought it would be nice to be able to do something like: Record.objects.filter( name='Dan' ).exists( RecordValue.objects.filter( value='django' ) ) I'm not sure how difficult it would be to implement, but I'd be willing to take a stab at it (against qs-rf once it's merged and/or stabilized) if it's of interest to anyone. Dan Note: This is unrelated to http://groups.google.com/group/django-developers/browse_frm/thread/5490f8736cc54c27/893ba34ec554bfc3 (although, interestingly, the name "any" was suggested in the that thread, which is what SQLAlchemy calls what I describe above - don't really care what the method is called) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers?hl=en -~----------~----~----~----~------~----~------~--~---