Merge branch 'master' of git://github.com/melinath/philo
[philo.git] / forms.py
index 57e772d..bf498fa 100644 (file)
--- a/forms.py
+++ b/forms.py
@@ -1,6 +1,7 @@
 from django import forms
 from django.contrib.admin.widgets import AdminTextareaWidget
 from django.core.exceptions import ValidationError, ObjectDoesNotExist
 from django import forms
 from django.contrib.admin.widgets import AdminTextareaWidget
 from django.core.exceptions import ValidationError, ObjectDoesNotExist
+from django.db.models import Q
 from django.forms.models import model_to_dict, fields_for_model, ModelFormMetaclass, ModelForm, BaseInlineFormSet
 from django.forms.formsets import TOTAL_FORM_COUNT
 from django.template import loader, loader_tags, TemplateDoesNotExist, Context, Template as DjangoTemplate
 from django.forms.models import model_to_dict, fields_for_model, ModelFormMetaclass, ModelForm, BaseInlineFormSet
 from django.forms.formsets import TOTAL_FORM_COUNT
 from django.template import loader, loader_tags, TemplateDoesNotExist, Context, Template as DjangoTemplate
@@ -280,7 +281,12 @@ class ContentReferenceInlineFormSet(ContainerInlineFormSet):
                super(ContentReferenceInlineFormSet, self).__init__(containers, data, files, instance, save_as_new, prefix, queryset)
        
        def get_container_instances(self, containers, qs):
                super(ContentReferenceInlineFormSet, self).__init__(containers, data, files, instance, save_as_new, prefix, queryset)
        
        def get_container_instances(self, containers, qs):
-               qs = qs.filter(name__in=[c[0] for c in containers])
+               filter = Q()
+               
+               for name, ct in containers:
+                       filter |= Q(name=name, content_type=ct)
+               
+               qs = qs.filter(filter)
                container_instances = []
                for container in qs:
                        container_instances.append(container)
                container_instances = []
                for container in qs:
                        container_instances.append(container)