Skip to content

Commit 225aad0

Browse files
committed
BACKWARDS INCOMPATIBLE CHANGE: Renamed the module from filter to django_filters, now it doesn't contend with the Python builtin filter.
1 parent 5bacaaa commit 225aad0

File tree

21 files changed

+62
-62
lines changed

21 files changed

+62
-62
lines changed

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ include AUTHORS.txt
22
include COPYRIGHT
33
include README.txt
44
recursive-include docs *
5-
recursive-include filter/fixtures *
6-
recursive-include filter/tests/templates/filter *
5+
recursive-include django_filters/fixtures *
6+
recursive-include django_filters/tests/templates/django_filters *

README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ admin's ``list_filter`` interface. It has an API very similar to Django's
77
``ModelForms``. For example if you had a Product model you could have a
88
filterset for it with the code::
99

10-
import filter
10+
import django_filters
1111

12-
class ProductFilterSet(filter.FilterSet):
12+
class ProductFilterSet(django_filters.FilterSet):
1313
class Meta:
1414
model = Product
1515
fields = ['name', 'price', 'manufacturer']

django_filters/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from django_filters.filterset import FilterSet
2+
from django_filters.filters import *

filter/fields.py renamed to django_filters/fields.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
from django import forms
22

3-
from filter.widgets import RangeWidget, LookupTypeWidget
3+
from django_filters.widgets import RangeWidget, LookupTypeWidget
44

55
class RangeField(forms.MultiValueField):
66
widget = RangeWidget
7-
7+
88
def __init__(self, *args, **kwargs):
99
fields = (
1010
forms.DecimalField(),
1111
forms.DecimalField(),
1212
)
1313
super(RangeField, self).__init__(fields, *args, **kwargs)
14-
14+
1515
def compress(self, data_list):
1616
if data_list:
1717
return slice(*data_list)
@@ -29,6 +29,6 @@ def __init__(self, field, lookup_choices, *args, **kwargs):
2929
widget = LookupTypeWidget(**defaults)
3030
kwargs['widget'] = widget
3131
super(LookupTypeField, self).__init__(fields, *args, **kwargs)
32-
32+
3333
def compress(self, data_list):
3434
return data_list

filter/filters.py renamed to django_filters/filters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.db.models.sql.constants import QUERY_TERMS
66
from django.utils.translation import ugettext_lazy as _
77

8-
from filter.fields import RangeField, LookupTypeField
8+
from django_filters.fields import RangeField, LookupTypeField
99

1010
__all__ = [
1111
'Filter', 'CharFilter', 'BooleanFilter', 'ChoiceFilter',

filter/filterset.py renamed to django_filters/filterset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from django.utils.datastructures import SortedDict
66
from django.utils.text import capfirst
77

8-
from filter.filters import Filter, CharFilter, BooleanFilter, ChoiceFilter, \
9-
DateFilter, DateTimeFilter, TimeFilter, ModelChoiceFilter, \
8+
from django_filters.filters import Filter, CharFilter, BooleanFilter, \
9+
ChoiceFilter, DateFilter, DateTimeFilter, TimeFilter, ModelChoiceFilter, \
1010
ModelMultipleChoiceFilter, NumberFilter
1111

1212
ORDER_BY_FIELD = 'o'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"pk": 1, "model": "django_filters.user", "fields": {"username": "alex", "status": 1, "first_name": "", "last_name": "", "favorite_books": [1, 2], "is_active": false}}, {"pk": 2, "model": "django_filters.user", "fields": {"username": "aaron", "status": 0, "first_name": "", "last_name": "", "favorite_books": [1, 3], "is_active": false}}, {"pk": 3, "model": "django_filters.user", "fields": {"username": "jacob", "status": 0, "first_name": "", "last_name": "", "favorite_books": [], "is_active": true}}, {"pk": 1, "model": "django_filters.comment", "fields": {"date": "2009-01-30", "text": "super awesome!", "time": "03:04:05", "author": 1}}, {"pk": 2, "model": "django_filters.comment", "fields": {"date": "2009-01-27", "text": "psycadelic!", "time": "05:04:03", "author": 2}}, {"pk": 3, "model": "django_filters.comment", "fields": {"date": "2008-12-31", "text": "funky fresh!", "time": "12:55:00", "author": 3}}, {"pk": 1, "model": "django_filters.book", "fields": {"average_rating": 4.7999999999999998, "price": "10", "title": "Ender's Game"}}, {"pk": 2, "model": "django_filters.book", "fields": {"average_rating": 4.5999999999999996, "price": "15", "title": "Rainbox Six"}}, {"pk": 3, "model": "django_filters.book", "fields": {"average_rating": 4.2999999999999998, "price": "20", "title": "Snowcrash"}}]
File renamed without changes.
File renamed without changes.

django_filters/tests/test_urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.conf.urls.defaults import *
2+
3+
from django_filters.models import Book
4+
5+
urlpatterns = patterns('',
6+
(r'^books/$', 'django_filters.views.object_filter', {'model': Book}),
7+
)

filter/tests/tests.py renamed to django_filters/tests/tests.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from django.conf import settings
55
from django.test import TestCase
66

7-
import filter
8-
from filter.models import User, Comment, Book, Restaurant, Article, STATUS_CHOICES
7+
import django_filters
8+
from django_filters.models import User, Comment, Book, Restaurant, Article, STATUS_CHOICES
99

1010

1111
class GenericViewTests(TestCase):
12-
urls = 'filter.tests.test_urls'
12+
urls = 'django_filters.tests.test_urls'
1313
fixtures = ['test_data']
1414
template_dirs = [
1515
os.path.join(os.path.dirname(__file__), 'templates'),
@@ -29,7 +29,7 @@ def test_generic_view(self):
2929

3030
class InheritanceTest(TestCase):
3131
def test_inheritance(self):
32-
class F(filter.FilterSet):
32+
class F(django_filters.FilterSet):
3333
class Meta:
3434
model = Book
3535

@@ -39,13 +39,13 @@ class G(F):
3939

4040
class ModelInheritanceTest(TestCase):
4141
def test_abstract(self):
42-
class F(filter.FilterSet):
42+
class F(django_filters.FilterSet):
4343
class Meta:
4444
model = Restaurant
4545

4646
self.assertEquals(set(F.base_filters), set(['name', 'serves_pizza']))
4747

48-
class F(filter.FilterSet):
48+
class F(django_filters.FilterSet):
4949
class Meta:
5050
model = Restaurant
5151
fields = ['name', 'serves_pizza']
@@ -56,8 +56,8 @@ class Meta:
5656
class DateRangeFilterTest(TestCase):
5757
def test_filter(self):
5858
a = Article.objects.create(published=datetime.datetime.today())
59-
class F(filter.FilterSet):
60-
published = filter.DateRangeFilter()
59+
class F(django_filters.FilterSet):
60+
published = django_filters.DateRangeFilter()
6161
class Meta:
6262
model = Article
6363
f = F({'published': '2'})
@@ -66,7 +66,7 @@ class Meta:
6666

6767
class FilterSetForm(TestCase):
6868
def test_prefix(self):
69-
class F(filter.FilterSet):
69+
class F(django_filters.FilterSet):
7070
class Meta:
7171
model = Restaurant
7272
fields = ['name']
@@ -77,10 +77,10 @@ class Meta:
7777
>>> from datetime import datetime
7878
>>> from django import forms
7979
>>> from django.core.management import call_command
80-
>>> import filter
81-
>>> from filter import FilterSet
82-
>>> from filter.widgets import LinkWidget
83-
>>> from filter.models import User, Comment, Book, STATUS_CHOICES
80+
>>> import django_filters
81+
>>> from django_filters import FilterSet
82+
>>> from django_filters.widgets import LinkWidget
83+
>>> from django_filters.models import User, Comment, Book, STATUS_CHOICES
8484
8585
>>> call_command('loaddata', 'test_data', verbosity=0)
8686
@@ -114,7 +114,7 @@ class Meta:
114114
</select></td></tr>
115115
116116
>>> class F(FilterSet):
117-
... status = filter.ChoiceFilter(widget=forms.RadioSelect, choices=STATUS_CHOICES)
117+
... status = django_filters.ChoiceFilter(widget=forms.RadioSelect, choices=STATUS_CHOICES)
118118
... class Meta:
119119
... model = User
120120
... fields = ['status']
@@ -145,7 +145,7 @@ class Meta:
145145
<tr><th><label for="id_username">Username:</label></th><td><input type="text" name="username" value="alex" id="id_username" /></td></tr>
146146
147147
>>> class F(FilterSet):
148-
... username = filter.CharFilter(action=lambda qs, value: qs.filter(**{'username__startswith': value}))
148+
... username = django_filters.CharFilter(action=lambda qs, value: qs.filter(**{'username__startswith': value}))
149149
... class Meta:
150150
... model = User
151151
... fields = ['username']
@@ -155,7 +155,7 @@ class Meta:
155155
[<User: alex>, <User: aaron>]
156156
157157
>>> class F(FilterSet):
158-
... status = filter.MultipleChoiceFilter(choices=STATUS_CHOICES)
158+
... status = django_filters.MultipleChoiceFilter(choices=STATUS_CHOICES)
159159
... class Meta:
160160
... model = User
161161
... fields = ['status']
@@ -248,7 +248,7 @@ class Meta:
248248
</select></td></tr>
249249
250250
>>> class F(FilterSet):
251-
... price = filter.NumberFilter(lookup_type='lt')
251+
... price = django_filters.NumberFilter(lookup_type='lt')
252252
... class Meta:
253253
... model = Book
254254
... fields = ['price']
@@ -273,7 +273,7 @@ class Meta:
273273
>>> f.qs
274274
[<User: alex>, <User: aaron>, <User: jacob>]
275275
>>> class F(FilterSet):
276-
... average_rating = filter.NumberFilter(lookup_type='gt')
276+
... average_rating = django_filters.NumberFilter(lookup_type='gt')
277277
... class Meta:
278278
... model = Book
279279
... fields = ['average_rating']
@@ -292,7 +292,7 @@ class Meta:
292292
[<Comment: jacob said funky fresh!>]
293293
294294
>>> class F(FilterSet):
295-
... price = filter.RangeFilter()
295+
... price = django_filters.RangeFilter()
296296
... class Meta:
297297
... model = Book
298298
... fields = ['price']
@@ -306,7 +306,7 @@ class Meta:
306306
[<Book: Ender's Game>, <Book: Rainbox Six>]
307307
308308
>>> class F(FilterSet):
309-
... price = filter.NumberFilter(lookup_type=None)
309+
... price = django_filters.NumberFilter(lookup_type=None)
310310
... class Meta:
311311
... model = Book
312312
... fields = ['price']
@@ -337,7 +337,7 @@ class Meta:
337337
<option value="year">year</option>
338338
</select></td></tr>
339339
>>> class F(FilterSet):
340-
... price = filter.NumberFilter(lookup_type=['lt', 'gt'])
340+
... price = django_filters.NumberFilter(lookup_type=['lt', 'gt'])
341341
... class Meta:
342342
... model = Book
343343
... fields = ['price']
@@ -358,7 +358,7 @@ class Meta:
358358
[<Book: Ender's Game>, <Book: Rainbox Six>, <Book: Snowcrash>]
359359
360360
>>> class F(FilterSet):
361-
... status = filter.ChoiceFilter(widget=LinkWidget, choices=STATUS_CHOICES)
361+
... status = django_filters.ChoiceFilter(widget=LinkWidget, choices=STATUS_CHOICES)
362362
... class Meta:
363363
... model = User
364364
... fields = ['status']
@@ -380,7 +380,7 @@ class Meta:
380380
</ul></td></tr>
381381
382382
>>> class F(FilterSet):
383-
... date = filter.DateRangeFilter(widget=LinkWidget)
383+
... date = django_filters.DateRangeFilter(widget=LinkWidget)
384384
... class Meta:
385385
... model = Comment
386386
... fields = ['date']
@@ -468,7 +468,7 @@ class Meta:
468468
[<User: alex>, <User: aaron>, <User: jacob>]
469469
470470
>>> class F(FilterSet):
471-
... price = filter.NumberFilter(lookup_type=['lt', 'gt', 'exact'])
471+
... price = django_filters.NumberFilter(lookup_type=['lt', 'gt', 'exact'])
472472
... class Meta:
473473
... model = Book
474474
... fields = ['price']

filter/views.py renamed to django_filters/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django.shortcuts import render_to_response
22
from django.template import RequestContext
33

4-
from filter.filterset import FilterSet
4+
from django_filters.filterset import FilterSet
55

66
def object_filter(request, model=None, queryset=None, template_name=None, extra_context=None,
77
context_processors=None, filter_class=None):
File renamed without changes.

docs/install.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Installing django-filter
22
------------------------
33

4-
To install, simply place the ``filter`` directory somehwere on your ``PYTHONPATH``,
5-
and then add ``'filter'`` to your ``INSTALLED_APPS``.
4+
To install, simply place the ``django_filters`` directory somehwere on your
5+
``PYTHONPATH``, and then add ``'django_filters'`` to your ``INSTALLED_APPS``.

docs/ref/filters.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ argument.
9595
The django.form Widget class which will represent the ``Filter``. In addition
9696
to the widgets that are included with Django that you can use there are
9797
additional ones that django-filte provides which may be useful:
98-
* ``filter.widgets.LinkWidget`` -- this displays the options in a mannner
99-
similar to the way the Django Admin does, as a series of links. The
100-
link for the selected option will have ``class="selected"``.
98+
* ``django_filters.widgets.LinkWidget`` -- this displays the options in a
99+
mannner similar to the way the Django Admin does, as a series of links.
100+
The link for the selected option will have ``class="selected"``.
101101

102102
``action``
103103
~~~~~~~~~~

docs/usage.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ model::
1818
We have a number of fields and we want to let our users filter based on the
1919
price or the release_date. We create a ``FilterSet`` for this::
2020

21-
import filter
21+
import django_filters
2222

23-
class ProductFilter(filter.FilterSet):
23+
class ProductFilter(django_filters.FilterSet):
2424
class Meta:
2525
model = Product
2626
fields = ['price', 'release_date']
@@ -30,10 +30,10 @@ As you can see this uses a very similar API to Django's ``ModelForm``. Just
3030
like with a ``ModelForm`` we can also overide filters, or add new ones using a
3131
declarative syntax::
3232

33-
import filter
33+
import django_filters
3434

35-
class ProductFilter(filter.FilterSet):
36-
price = filter.NumberFilter(lookup_type='lt')
35+
class ProductFilter(django_filters.FilterSet):
36+
price = django_filters.NumberFilter(lookup_type='lt')
3737
class Meta:
3838
model = Product
3939
fields = ['price', 'release_date']
@@ -47,7 +47,7 @@ Filters also take any arbitrary keyword arguments which get passed onto the
4747
in ``Filter.extra``, so it's possible to overide the constructor of a
4848
``FilterSet`` to add extra ones::
4949

50-
class ProductFilterSet(filter.FilterSet):
50+
class ProductFilterSet(django_filters.FilterSet):
5151
class Meta:
5252
model = Product
5353
fields = ['manufacturer']
@@ -103,6 +103,6 @@ Generic View
103103
============
104104

105105
In addition to the above usage there is also a generic view included in
106-
django-filter, which lives at ``filter.view.object_filter``. You must provide
107-
either a ``model`` or ``filter_class`` argument, similar to the
106+
django-filter, which lives at ``django_filters.view.object_filter``. You must
107+
provide either a ``model`` or ``filter_class`` argument, similar to the
108108
``create_update`` view in Django itself.

filter/__init__.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

filter/fixtures/test_data.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

filter/tests/test_urls.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
'Framework :: Django',
2424
],
2525
package_data = {
26-
'filter': [
26+
'django_filters': [
2727
'fixtures/*.json',
2828
],
29-
'filter.tests': [
30-
'templates/filter/*.html',
29+
'django_filters.tests': [
30+
'templates/django_filters/*.html',
3131
]
3232
},
3333
zip_safe=False,

0 commit comments

Comments
 (0)