Permalink
Browse files

added gitignore and notes

  • Loading branch information...
1 parent e308ecd commit ff5834cf61ae3824ab4dbe72ad6acf2bd86b3654 @alex alex committed Jan 29, 2009
Showing with 30 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +29 −0 notes.txt
View
@@ -0,0 +1 @@
+*.pyc
View
@@ -0,0 +1,29 @@
+Filterer
+========
+
+Usage:
+
+class EntryFilterer(filter.Filterer):
+ author = filter.ChoiceFilterer(widget=forms.CheckBox)
+ has_comments = filter.BooleanFilterer(action = lambda qs: qs.annotate(num_comments=Count('comments')).filter(num_comments__gt=0))
+
+ class Meta:
+ model = Entry
+ fields = ["title", "author"]
+
+def my_view(request):
+ f = EntryFilterer(request.GET)
+ return render_to_respones("template.html", {'f': f})
+
+{% extends "base.html" %}
+
+{% block content %}
+ {{ f.filters }}
+ {% for entry in f %}
+ {{ entry.title }}
+ {% endfor %}
+{% endblock %}
+
+Similar structure to ModelForms, Meta sets the model and fields/excludes. You
+can overide a filterer, set it's widget to the form field widget, provide a
+custom action.

0 comments on commit ff5834c

Please sign in to comment.