Use it at your own risk! Alpha-dev version, as is.
- Twitter Bootstrap 2.3+
- jQuery 1.9+
- Open your shell,
cd /to/some/path
- Run
git clone https://github.com/fynjah/django-pimp-my-filter.git
- Run
cd django-pimp-my-filter
- Run
[sudo] python setup.py install
- Now app is installed.
- Open
settings.py
of your project. At the end of the file writeINSTALLED_APPS += ('filter_manager',)
. - Also add this:
PIMP_MY_FILTER = { 'ALLOWED_MODELS': ( 'your_app1.your_model1', 'your_app2.your_model2', ... 'appN.modelN', ), }Any other models will be ignored with error. 3. Open ``urls.py`` file. Edit ``urlpatterns`` by adding ``('^pimp-my-filter/', include('filter_manager.urls')),`` 4. Open your shell, find your project and run `python manage.py syncdb`. 5. Insert [this code](https://raw.github.com/fynjah/django-pimp-my-filter/master/filter_manager/templates/base.html) to your template, somewhere. 6. Insert ``{%load% static%}`` and ``{% get_static_prefix as static_prefix %}`` to your template, at the top of the file. 7. Insert somewhere *after* jQuery and Twitter Bootstrap inits, this: ``<script type="text/javascript" src="{{ static_prefix }}filter_manager/filter_manager.js "></script>``
- Place somewhere in template, this:
$(document).ready(function(){ $(document).on('click', '#new-filter-button', function(e){ e.preventDefault() $('#new-filter').pimpMyFilter({ name:'Name of your modal', app:'your_app_to_use_filter_manager', model:'your_model_of_the_app_to_use_filter', modalWidth:1000, //width of modal, req. from "800" to "1000". But, anyway it's fluid. default:"800" url:"/your_url_pattern_to_filter_manager/" //default: "/pimp-my-filter/", limit:10, //default: '0'. Limit num of conditions. }); }); });
- Start your project, jump to page with edited template and click this pretty button
New filter
- You'll see modal window, something like on the pic at the top of this README.
- Try to select some field. Each type of field has own
value
field, that corresponds to type of field in model.- Try to select
ForeignKey
field(find name of field in your model), and try to start typing invalue
field.- That's it.
- Resize modal:
pimpMyFilter.setModalWidth(1000)
- Redefine
value
field( not tested ):pimpFields.[type_of_field] = function(ModelField){ //ModelField comes from pimpMyFilter.settings.structure //ModelField = {"name":"some_name","type":"some_type"}. Use it. field = this.__AbstractInputField(); //or field = this.__AbstractSelectField(); //.. //... Your definition of field, e.g field.css(), etc //.. return field; }- Get filters by current user:
pimpMyFilter.getFiltersByUser();It returs object with
id
,name
andquick
. 4. Use saved filter:pimpMyFilter.userFilter(filter_id);where
filter_id
- is frompimpMyFilter.getFiltersByUser();
- Some bugs with HTML markup, but works nice with Chrome.
- For this moment you CAN use filters, but some fields do not work at this moment.
- Lot of other bugs, which I will fix soon:)
- Tags
- Fix fields in
views.py
- API
PS: This app is designed for modern browsers! Stop supporting old versions of IE!