Hey guys,

I've been using a subclass of BaseInlineFormSet that takes queryset as
an argument and I thought that maybe this would be something other
people would want. So I thought I'd ask here before submitting a
feature request / patch...

Is this something other people want?

This is how I subclassed it:

class QuerysetInlineFormSet(BaseInlineFormSet):
    def __init__(self, data=None, files=None, instance=None,
save_as_new=False, prefix=None, queryset=None):
        if queryset == None:
                self.sm_queryset = self.model._default_manager.all()
        else:
                self.sm_queryset = queryset
        super(QuerysetInlineFormSet, self).__init__(data, files,
instance=instance, save_as_new = save_as_new, prefix=prefix)

    def get_queryset(self):
        kwargs = {self.fk.name: self.instance}
        return self.sm_queryset.filter(**kwargs)

(I used "sm_" just in case any parent classes referenced self.queryset
explicitly. And I test for "queryset==None" so that empty querysets
don't get overwritten)

Any comments?

Thanks,

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-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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to