A better and faster multiple selection widget with suggestions

Overview

django-searchable-select

Build Status Coverage Status

A better and faster multiple selection widget with suggestions for Django

This project is looking for maintainers!

Please open an issue to request write access.

What is this?

This plugin provides a replacement for standard multi-choice select on Django admin pages.

You can use this as custom widget for ManyToManyField.

Features

  • Filtering is performed on server side and thus significantly improves performance.
  • Uses Twitter Typeahead to provide suggestion completion.
  • Works great with ManyToMany fields that can be chosen from thousands of thousands of choices, e. g. User - City relations.

Before

Before

After

Before

Installation

  1. Install django-searchable-select.

    $ pip install django-searchable-select
  2. Add 'searchableselect' to your settings.

    # settings.py
    
    INSTALLED_APPS = (
        # ...
        'searchableselect',
        # ...
    )
  3. Add URL pattern required for the suggesting engine to your root urls.py.

    # urls.py
    
    urlpatterns = patterns(
        '',
        # ...
        url('^searchableselect/', include('searchableselect.urls')),
        # ...
    )
  4. Use the widget in your model admin class:

    from django import models, forms
    from searchableselect.widgets import SearchableSelect
    from models import Traveler
    
    class TravelerForm(forms.ModelForm):
        class Meta:
            model = Traveler
            exclude = ()
            widgets = {
                'cities_visited': SearchableSelect(model='cities.City', search_field='name', many=True, limit=10)
            }
    
    
    class TravelerAdmin(admin.ModelAdmin):
        form = TravelerForm
    
    admin.site.register(Traveler, TravelerAdmin)

    Remember to always initialize SearchableSelect with three keyword arguments: model, search_field and many.

    • model is the string in form APP_NAME.MODEL_NAME representing your model in the project, e. g. 'cities.City'
    • search_field is the field within model that will be used to perform filtering, e. g. 'name'
    • many must be True for ManyToManyField and False for ForeignKey.
    • limit (optional) specifies the maximum count of entries to retrieve.

Example app

Just run the project from example directory, head to http://127.0.0.1:8000, login as admin/admin and try adding Cats!

Supported versions

  • Python 2.7.x: Django 1.7, 1.8, 1.9, 1.10
  • Python 3.x: Django 1.8, 1.9, 1.10, 2.0

Testing

In order to support multiple Django and Python versions we use:

  • py.test - test runner
  • tox - handy tool to test app with different versions of Pythons & libraries
  • selenium
  • coverage

Install them via pip install -r requirements/dev.txt

To test things in specific environment, run the following commands:

# Clear previous coverage data.
coverage erase

# This command can be ran multiple times.
tox -e <python_ver>-<django_ver>
# Possible python_ver values: `py27`, `py36`
# Possible django_ver values: `17`, `18`, `19`, `110`, '20'
# Values can be comma-separated, e. g. `-e py27-17,py27-18,py36-18`
# If you omit `-e ...` parameter, all environments will be tests.
# Also - not problems with running this within a virtualenv.
# Check tox.ini for these values.

# Run this once all tests passed on all environment.
coverage combine

# Render HTML with coverage info.
coverage html
# ...or simply display % of covered SLOC for each file.
coverage report

To add a new Django version for testing, add it into tox.ini, lines 3-4.

Why do we need tox and coverage combine? Because different versions of Python & libraries lead to different code execution: for example, consider this code:

import sys
if sys.version_info.major == 2:
    foo = 'spam'  # Not covered in Python 3.x, leads to coverage < 100%
else:
    foo = 'eggs'  # Not covered in Python 2.x, leads to coverage < 100%

Using tox and coverage combine we're able to "merge" coverage info from across different environments.

Known issues

  • Not tested with empty fields.
  • Tests sometimes fail randomly due to some Selenium timeout issue. Weird.

Contributing

I'm looking forward to bug reports and any kind of contribution.

License

You are free to use this where you want as long as you keep the author reference. Please see LICENSE for more info.

Comments
  • Added fallback for django 1.11

    Added fallback for django 1.11

    There is error when I tried to implement searchable select in django 1.11, I fixed it using the code in this pull request. Please review the code and merge it.

    opened by sheeshmohsin 9
  • AttributeError: type object 'MyModel' has no attribute 'split'

    AttributeError: type object 'MyModel' has no attribute 'split'

    Hey, I am not sure if I misunderstood the docs but when I add widgets = {'myfield': SearchableSelect(model='MyModel', search_field='myfield', many=True, limit=10)} to my form it throws this error. Any pointers would be highly appreciated 😄

    opened by marrip 3
  • support multiple search fields

    support multiple search fields

    @and3rson I think it would be great if

    widgets = {
        'user': SearchableSelect(model='users.User',
                                 search_field='email',
                                 many=False, limit=10),
    }
    

    will be

    widgets = {
        'user': SearchableSelect(model='users.User',
                                 search_field=['email', 'first_name', 'last_name'],
                                 many=False, limit=10),
    }
    

    If you agree I will make it.

    duplicate enhancement 
    opened by shalakhin 3
  • A maximum of 5 selections are listed for a foreign key.

    A maximum of 5 selections are listed for a foreign key.

    Although views.filter_models limits the result to 10 items, only 5 show up in the selection. I've changed the array slice from 10 to 30 items (for example) but still only see 5. I added a print() statement to verify that I'm actually retrieving more than 5 items in filter_models.

    My assumption is that there's a limit somewhere within JQuery or elsewhere but I don't know where it is/can't find it.

    It would be better if there were a parameter to limit the results rather than the hard coded array slice value, especially since there seems to be another limit elsewhere.

    Django 1.10.5 Problem occurs in both Safari 10.0.3 and Chrome 56.0.2924.87 (64-bit) on macOS 10.12.3.

    NOTE: This is for a foreign key (with ~76k rows).

    bug enhancement Fixed 
    opened by konohitowa 3
  • Bump django from 1.10.2 to 1.11.23 in /example

    Bump django from 1.10.2 to 1.11.23 in /example

    Bumps django from 1.10.2 to 1.11.23.

    Commits
    • 9748977 [1.11.x] Bumped version for 1.11.23 release.
    • 869b34e [1.11.x] Fixed CVE-2019-14235 -- Fixed potential memory exhaustion in django....
    • ed682a2 [1.11.x] Fixed CVE-2019-14234 -- Protected JSONField/HStoreField key and inde...
    • 52479ac [1.11.x] Fixed CVE-2019-14233 -- Prevented excessive HTMLParser recursion in ...
    • 42a66e9 [1.11.X] Fixed CVE-2019-14232 -- Adjusted regex to avoid backtracking issues ...
    • 693046e [1.11.x] Added stub release notes for security releases.
    • 6d054b5 [1.11.x] Added CVE-2019-12781 to the security release archive.
    • 7c849b9 [1.11.x] Post-release version bump.
    • 480380c [1.11.x] Bumped version for 1.11.22 release.
    • 32124fc [1.11.x] Fixed CVE-2019-12781 -- Made HttpRequest always trust SECURE_PROXY_S...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 2
  • Not able to render in django 1.11

    Not able to render in django 1.11

    Below is the error I got in django 1.11, however I worked fine in 1.10, Can you please point me from where the error i am getting, so that I can try to fix it?

    Traceback (most recent call last):
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
        response = get_response(request)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/core/handlers/base.py", line 217, in _get_response
        response = self.process_exception_by_middleware(e, request)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/core/handlers/base.py", line 215, in _get_response
        response = response.render()
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/response.py", line 107, in render
        self.content = self.rendered_content
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/response.py", line 84, in rendered_content
        content = template.render(context, self._request)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
        return self.template.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 207, in render
        return self._render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/test/utils.py", line 107, in instrumented_test_render
        return self.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
        return compiled_parent._render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/test/utils.py", line 107, in instrumented_test_render
        return self.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
        return compiled_parent._render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/test/utils.py", line 107, in instrumented_test_render
        return self.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
        return compiled_parent._render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/test/utils.py", line 107, in instrumented_test_render
        return self.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 72, in render
        result = block.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 72, in render
        result = block.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 216, in render
        nodelist.append(node.render_annotated(context))
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 216, in render
        return template.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 209, in render
        return self._render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/test/utils.py", line 107, in instrumented_test_render
        return self.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 216, in render
        nodelist.append(node.render_annotated(context))
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 216, in render
        nodelist.append(node.render_annotated(context))
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 216, in render
        return template.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 209, in render
        return self._render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/test/utils.py", line 107, in instrumented_test_render
        return self.nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 216, in render
        nodelist.append(node.render_annotated(context))
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 216, in render
        nodelist.append(node.render_annotated(context))
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 322, in render
        return nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 322, in render
        return nodelist.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 990, in render
        bit = node.render_annotated(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
        return self.render(context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 1046, in render
        return render_value_in_context(output, context)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/template/base.py", line 1024, in render_value_in_context
        value = force_text(value)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/utils/encoding.py", line 78, in force_text
        s = six.text_type(s)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/utils/html.py", line 376, in <lambda>
        klass.__unicode__ = lambda self: mark_safe(klass_unicode(self))
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/forms/boundfield.py", line 41, in __str__
        return self.as_widget()
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/forms/boundfield.py", line 120, in as_widget
        **kwargs
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/forms/widgets.py", line 220, in render
        context = self.get_context(name, value, attrs)
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/django/contrib/admin/widgets.py", line 281, in get_context
        'rendered_widget': self.widget.render(name, value, attrs),
      File "/Users/sheeshmohsin/envdashboard/lib/python2.7/site-packages/searchableselect/widgets.py", line 55, in render
        final_attrs = self.build_attrs(attrs, name=name)
    TypeError: build_attrs() got an unexpected keyword argument 'name'
    
    bug Fixed 
    opened by sheeshmohsin1 2
  • Bump django from 1.10.2 to 1.11.29 in /example

    Bump django from 1.10.2 to 1.11.29 in /example

    Bumps django from 1.10.2 to 1.11.29.

    Commits
    • f1e3017 [1.11.x] Bumped version for 1.11.29 release.
    • 02d97f3 [1.11.x] Fixed CVE-2020-9402 -- Properly escaped tolerance parameter in GIS f...
    • e643833 [1.11.x] Pinned PyYAML < 5.3 in test requirements.
    • d0e3eb8 [1.11.x] Added CVE-2020-7471 to security archive.
    • 9a62ed5 [1.11.x] Post-release version bump.
    • e09f09b [1.11.x] Bumped version for 1.11.28 release.
    • 001b063 [1.11.x] Fixed CVE-2020-7471 -- Properly escaped StringAgg(delimiter) parameter.
    • 7fd1ca3 [1.11.x] Fixed timezones tests for PyYAML 5.3+.
    • 121115d [1.11.x] Added CVE-2019-19844 to the security archive.
    • 2c4fb9a [1.11.x] Post-release version bump.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump django from 1.10.2 to 1.11.28 in /example

    Bump django from 1.10.2 to 1.11.28 in /example

    Bumps django from 1.10.2 to 1.11.28.

    Commits
    • e09f09b [1.11.x] Bumped version for 1.11.28 release.
    • 001b063 [1.11.x] Fixed CVE-2020-7471 -- Properly escaped StringAgg(delimiter) parameter.
    • 7fd1ca3 [1.11.x] Fixed timezones tests for PyYAML 5.3+.
    • 121115d [1.11.x] Added CVE-2019-19844 to the security archive.
    • 2c4fb9a [1.11.x] Post-release version bump.
    • 358973a [1.11.x] Bumped version for 1.11.27 release.
    • f4cff43 [1.11.x] Fixed CVE-2019-19844 -- Used verified user email for password reset ...
    • a235574 [1.11.x] Refs #31073 -- Added release notes for 02eff7ef60466da108b1a33f1e4dc...
    • e8fdf00 [1.11.x] Fixed #31073 -- Prevented CheckboxInput.get_context() from mutating ...
    • 4f15016 [1.11.x] Post-release version bump.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  •  Make widget compatible with Django 2.1

    Make widget compatible with Django 2.1

    Support for Widget.render() methods without the renderer argument is going to be removed in Django 2.1. This PR makes widget compatible with Django 2.1

    opened by treemo 1
  • Integration with Add related record (+)

    Integration with Add related record (+)

    Hello,

    I noticed on the homepage readme you also have the (+) button. Right now it just inserts the unique ID into the form field and that's it. Is there any way to have it automatically create the relationship + tag view ?

    opened by notsoluckycharm 1
  • error occurs when unicode search

    error occurs when unicode search

    error log:

    Internal Server Error: /searchableselect/filter
    Traceback (most recent call last):
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\django\core\handlers\exception.py", line 39, in inner
        response = get_response(request)
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\django\core\handlers\base.py", line 249, in _legacy_get_response
        response = self._get_response(request)
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\django\core\handlers\base.py", line 187, in _get_response
        response = self.process_exception_by_middleware(e, request)
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\django\core\handlers\base.py", line 185, in _get_response
        response = wrapped_callback(request, *callback_args, **callback_kwargs)
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\django\contrib\auth\decorators.py", line 23, in _wrapped_view
        return view_func(request, *args, **kwargs)
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\searchableselect\views.py", line 25, in filter_models
        in values
      File "C:\Anaconda3\envs\djangoadmin2\lib\site-packages\searchableselect\views.py", line 24, in <listcomp>
        for value
    NameError: name 'unicode' is not defined
    
    

    change

    dict(pk=value.pk, name=unicode(value))

    to

    from django.utils.encoding import smart_str
    ... ...
    dict(pk=value.pk, name=smart_str(value))
    

    will be ok.

    bug Fixed 
    opened by malongge 1
  • Django 4.0, Remove support to older Django and Python versions and improvements

    Django 4.0, Remove support to older Django and Python versions and improvements

    • Made fixes to make it work with Django 4.0.
    • Drop support to Python 2 and Python < 3.5 that are unmaintained and insecure.
    • Drop support to Django < 2.2 that also reach end of mainstream support (insecure).
    • Drop included jQuery version used in favor of built-in django.jQuery in Django that is more up to date and maintained by Django, making also the library less vulnerable and lightweight.
    • Fix margin in "chips", specially margin top was 0, making it ugly.
    • Fix Tox and Selenium configurations. Replace PhantomJS with Chrome (PhantomJS support was removed in newer versions of Selenium).
    • Replace Travis CI with GitHub Actions: Travis is fading out its commitment with OSS, making the service for no-paid projects each time slower and less available. On the other hand GH Actions is free and fast even for OSS projects.
    • Remove IDE configurations that are "user" related.
    opened by mrsarm 10
  • ImportError: cannot import name 'url' from 'django.conf.urls' on Django 4.0

    ImportError: cannot import name 'url' from 'django.conf.urls' on Django 4.0

    I discovered your project today while researching some stuff and tried to include it into my project. This failed as Django 4.0 removed the django.conf.urls.url method which had been deprecated in Django 3.0.

    For this reason I am currently using a workaround in my urls.py file:

    from django.urls import path, include
    from searchableselect.views import filter_models as searchable_select_filter_models
    
    urlpatterns = [
        # Original solution does not work for Django 4.0.
        # path("searchableselect/", include("searchableselect.urls")),
        path(
            "searchable-select/",
            searchable_select_filter_models,
            name="searchable-select-filter",
        ),
    ]
    

    As far as I have seen, the other functionality seems to work with Django 4.0.

    opened by FriedrichFroebel 1
  • Bump django from 1.10.2 to 2.2.24 in /example

    Bump django from 1.10.2 to 2.2.24 in /example

    Bumps django from 1.10.2 to 2.2.24.

    Commits
    • 2da029d [2.2.x] Bumped version for 2.2.24 release.
    • f27c38a [2.2.x] Fixed CVE-2021-33571 -- Prevented leading zeros in IPv4 addresses.
    • 053cc95 [2.2.x] Fixed CVE-2021-33203 -- Fixed potential path-traversal via admindocs'...
    • 6229d87 [2.2.x] Confirmed release date for Django 2.2.24.
    • f163ad5 [2.2.x] Added stub release notes and date for Django 2.2.24.
    • bed1755 [2.2.x] Changed IRC references to Libera.Chat.
    • 63f0d7a [2.2.x] Refs #32718 -- Fixed file_storage.test_generate_filename and model_fi...
    • 5fe4970 [2.2.x] Post-release version bump.
    • 61f814f [2.2.x] Bumped version for 2.2.23 release.
    • b8ecb06 [2.2.x] Fixed #32718 -- Relaxed file name validation in FileField.
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Fix Double trigger

    Fix Double trigger

    Prevent Double click trigger that override selecting when pressing Enter after selecting a chip

    To reproduce :

    • Start tiping something
    • Select a chip that is not the first one
    • Press Enter

    Selection will be overriten before form validation and will select the first chip in current search query

    opened by Maxmystere 0
Releases(1.5.0)
Owner
Andrew Dunai
Codin' around.
Andrew Dunai
Location field and widget for Django. It supports Google Maps, OpenStreetMap and Mapbox

django-location-field Let users pick locations using a map widget and store its latitude and longitude. Stable version: django-location-field==2.1.0 D

Caio Ariede 481 Dec 29, 2022
The magical reactive component framework for Django ✨

Unicorn The magical full-stack framework for Django ✨ Unicorn is a reactive component framework that progressively enhances a normal Django view, make

Adam Hill 1.4k Jan 05, 2023
A feature flipper for Django

README Django Waffle is (yet another) feature flipper for Django. You can define the conditions for which a flag should be active, and use it in a num

950 Dec 26, 2022
Django web apps for managing schedules.

skdue Description Skdue is a web application that makes your life easier by helping you manage your schedule. With the ability which allows you to cre

Patkamon_Awai 1 Jun 30, 2022
Django-pwned - A collection of django password validators

Django Pwned A collection of django password validators. Compatibility Python: 3

Quera 22 Jun 27, 2022
Money fields for Django forms and models.

django-money A little Django app that uses py-moneyed to add support for Money fields in your models and forms. Django versions supported: 1.11, 2.1,

1.4k Jan 06, 2023
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

Victor Aderibigbe 18 Sep 09, 2022
Dynamic Django settings.

Constance - Dynamic Django settings A Django app for storing dynamic settings in pluggable backends (Redis and Django model backend built in) with an

Jazzband 1.5k Jan 07, 2023
Alt1-compatible widget host for RuneScape 3

RuneKit Alt1-compatible toolbox for RuneScape 3, for Linux and macOS. Compatibility macOS installation guide Running This project use Poetry as packag

Manatsawin Hanmongkolchai 75 Nov 28, 2022
A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework

music-recommender-rest-api A music recommendation REST API which makes a machine learning algorithm work with the Django REST Framework How it works T

The Reaper 1 Sep 28, 2021
A Django backed for PostgreSQL using Psycopg 3

A Django backend for PostgreSQL using Psycopg 2 The backend passes the entire Django test suite, but it needs a few modifications to Django and to i

Daniele Varrazzo 42 Dec 16, 2022
Faker is a Python package that generates fake data for you.

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in yo

Daniele Faraglia 15.2k Jan 01, 2023
Django server-side adapter for Inertia.js

django-inertia Django server-side new adapter for Inertia.js. Getting Started Install the package pip install django-inertia Configure your project A

Samuel Girardin 14 Sep 16, 2022
A reusable Django model field for storing ad-hoc JSON data

jsonfield jsonfield is a reusable model field that allows you to store validated JSON, automatically handling serialization to and from the database.

Ryan P Kilby 1.1k Jan 03, 2023
simple project management tool for educational purposes

Taskcamp This software is used for educational and demonstrative purposes. It's a simple project management tool powered by Django Framework Install B

Ilia Dmitriev 6 Nov 08, 2022
✋ Auto logout a user after specific time in Django

django-auto-logout Auto logout a user after specific time in Django. Works with Python 🐍 ≥ 3.7, Django 🌐 ≥ 3.0. ✔️ Installation pip install django-a

Georgy Bazhukov 21 Dec 26, 2022
Simply integrate Summernote editor with Django project.

django-summernote Summernote is a simple WYSIWYG editor. django-summernote allows you to embed Summernote into Django very handy. Support admin mixins

Summernote 936 Jan 02, 2023
Management commands to help backup and restore your project database and media files

Django Database Backup This Django application provides management commands to help backup and restore your project database and media files with vari

687 Jan 04, 2023
Easily share data across your company via SQL queries. From Grove Collab.

SQL Explorer SQL Explorer aims to make the flow of data between people fast, simple, and confusion-free. It is a Django-based application that you can

Grove Collaborative 2.1k Dec 30, 2022
Pipeline is an asset packaging library for Django.

Pipeline Pipeline is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript templ

Jazzband 1.4k Jan 03, 2023