Skip to content

Commit

Permalink
Merge pull request #40 from modlinltd/feature/select2-fail-to-load
Browse files Browse the repository at this point in the history
Feature/select2 fail to load
  • Loading branch information
asfaltboy authored Feb 26, 2017
2 parents 423316f + f6cd55e commit 9831ba5
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ tests/db.sqlite*
/.eggs/
/htmlcov/
/advanced_filters/.coverage

/tests/local.db
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ Requirements
============

- Django >= 1.5 (Django 1.5 - 1.9 on Python 2/3/PyPy2)
- django-easy-select2 == 1.2.5
- django-braces == 1.4.0
- simplejson == 3.6.5

*NOTE*: While the latest Django 1.5.X is supported, the bundled jQuery it includes is outdated (1.4.2) and as such, most of our admin frontend scripts fail. This means that to use advanced-filters in Django 1.5 admin, you'd have to probably include your own jQuery (1.9 or later) and add it to global namespace prior to other scripts in `AdvancedFilterForm.Meta`.

Installation & Set up
=====================

1. Install from pypi: ``pip install django-advanced-filters``
2. Add both ``'advanced_filters'`` and ``'easy_select2'`` to
``INSTALLED_APPS``.
2. Add both ``'advanced_filters'`` to ``INSTALLED_APPS``.
3. Add ``url(r'^advanced_filters/', include('advanced_filters.urls'))``
to your project's urlconf.
4. Run ``python manage.py syncdb`` or ``python manage.py migrate`` (for django >= 1.7)
Expand Down
2 changes: 1 addition & 1 deletion advanced_filters/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class Media:
('' if settings.DEBUG else '.min')),
static('magnific-popup/jquery.magnific-popup.js'),
static('advanced-filters/advanced-filters.js'), ]
js = [SELECT2_JS] + required_js
js = required_js + [SELECT2_JS]
css = {'screen': [static(SELECT2_CSS), static('advanced-filters/advanced-filters.css'),
static('magnific-popup/magnific-popup.css')]}

Expand Down
4 changes: 4 additions & 0 deletions advanced_filters/static/advanced-filters/advanced-filters.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@
}
.empty-form {
display: none;
}

.select2-container {
min-width: 166px;
}
2 changes: 2 additions & 0 deletions advanced_filters/static/advanced-filters/advanced-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ var OperatorHandlers = function($) {
$(this).data('pre_change', $(this).val());
}).change();
});
self.field_selected($('.form-row select.query-field').first());

};

self.destroy = function() {
Expand Down
14 changes: 14 additions & 0 deletions tests/test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'debug': True,
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
}
},
]

Expand Down

0 comments on commit 9831ba5

Please sign in to comment.