Saturday, February 14, 2009

Announcing django-filter

Django-filter is a reusable Django application I have been working on for a few weeks, individuals who follow me on Github may have noticed me working on it. Django-filter is basically an application that creates a generic interface for creating pages like the Django admin changelist page. It has support for defining vairous filters(including custom ones), filtering a queryset based on the user selections, and displaying an HTML form for the filter options. It has a design based around Django's ModelForm.

You can get the code, as well as tests and docs over at Github. For all bug reports, comments, and other feedback you can send me a message on Github(or message me on IRC) until I figure out a proper bug tracking system.

Enjoy.

11 comments:

  1. Yay, I was just dreaming about something like that! hehe.

    kudos for Alex, time for django.contrib.filters ? ;)))

    ReplyDelete
  2. Good work. I also made an app like this, but it's still in test phase. It's also based in ModelForm, but has some differences. Latelly I can show you.

    ReplyDelete
  3. I have been using something for filters since a long time too, but your solution looks a lot cleaner.
    I will definitely try this out.

    ReplyDelete
  4. Thanks Alex,

    I really like using you app!

    Is it true that (Positive)IntegerFields are not supported yet?

    Many thanks!

    ReplyDelete
  5. This is a very useful app. Thank you!

    Ran into a problem with 'ModelMultipleChoiceFilter'.


    class WorkListFilter(FilterSet):
    status = ModelMultipleChoiceFilter()
    class Meta:
    model = Work
    fields = ['status']

    ('status' is a foreignkey to another model)



    File "/Site/user/views.py", line 27, in WorkListFilter
    status = ModelMultipleChoiceFilter()

    File "/Site/filter/filters.py", line 38, in __init__
    self.field = self.field(required=False, label=label, widget=widget, **kwargs)

    TypeError: __init__() takes at least 2 non-keyword arguments (1 given)


    any ideas?

    ReplyDelete
  6. Michael, please file a bug at github and I'll look into it.

    ReplyDelete
  7. Michael, you should define queryset:

    status = ModelMultipleChoiceFilter(queryset=...)

    ReplyDelete
  8. Boris, thank you, that works!

    Alex, thanks for your continued work on this great django-app.. very much appreciated!

    ReplyDelete
  9. Hi Alex,
    I happened to not notice your announcement and started working in the same direction almost simultaneously, but much slower and at first without a clear vision of the results. At this point your code seems to be much better thought-out and more complete.
    I'll consider switching to your application.
    Thanks for this excellent work! :-)

    ReplyDelete
  10. Hello,
    I created something similar but more close to the Admin Filters. Actually I just subclassed the Admin Changelist. So it uses the options defined for the ModelAdmin class. It also provides template tags for inserting filter html. It uses GET variables directly through links rather than a form.

    ReplyDelete

Note: Only a member of this blog may post a comment.