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
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
DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

DRF_commands is a Django package that helps you to create django rest framework endpoints faster using manage.py.

Mokrani Yacine 2 Sep 28, 2022
Utilities to make function-based views cleaner, more efficient, and better tasting.

django-fbv Utilities to make Django function-based views cleaner, more efficient, and better tasting. ?? ?? Complete documentation: https://django-fbv

Adam Hill 49 Dec 30, 2022
Neighbourhood - A python-django web app to help the residence of a given neighborhood know their surrounding better

Neighbourhood A python-django web app to help the residence of a given neighborh

Levy Omolo 4 Aug 25, 2022
Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards and optional settings files.

Organize Django settings into multiple files and directories. Easily override and modify settings. Use wildcards in settings file paths and mark setti

Nikita Sobolev 940 Jan 3, 2023
A CBV to handle multiple forms in one view

django-shapeshifter A common problem in Django is how to have a view, especially a class-based view that can display and process multiple forms at onc

Kenneth Love 167 Nov 26, 2022
A Django web application to receive, virus check and validate transfers of digital archival records, and allow archivists to appraise and accession those records.

Aurora Aurora is a Django web application that can receive, virus check and validate transfers of digital archival records, and allows archivists to a

Rockefeller Archive Center 20 Aug 30, 2022
Django application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

null 2.6k Dec 26, 2022
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

null 687 Jan 4, 2023
Plug and play continuous integration with django and jenkins

django-jenkins Plug and play continuous integration with Django and Jenkins Installation From PyPI: $ pip install django-jenkins Or by downloading th

Mikhail Podgurskiy 941 Oct 22, 2022
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App ?? We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:

Stream Framework Activity Streams & Newsfeeds Stream Framework is a Python library which allows you to build activity streams & newsfeeds using Cassan

Thierry Schellenbach 4.7k Jan 2, 2023
A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, celery and redis.

Django Channels Websocket Chatbot A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, c

Yunbo Shi 8 Oct 28, 2022
Forward and backwards compatibility layer for Django 1.4, 1.7, 1.8, 1.9, 1.10, and 1.11

django-compat Forward and backwards compatibility layer for Django 1.4 , 1.7 , 1.8, 1.9, 1.10 and 1.11 Consider django-compat as an experiment based o

arteria GmbH 106 Mar 28, 2022
The best way to have DRY Django forms. The app provides a tag and filter that lets you quickly render forms in a div format while providing an enormous amount of capability to configure and control the rendered HTML.

django-crispy-forms The best way to have Django DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered

null 4.6k Jan 7, 2023
A simple Blog Using Django Framework and Used IBM Cloud Services for Text Analysis and Text to Speech

ElhamBlog Cloud Computing Course first assignment. A simple Blog Using Django Framework and Used IBM Cloud Services for Text Analysis and Text to Spee

Elham Razi 5 Dec 6, 2022
Median and percentile for Django and MongoEngine

Tailslide Median and percentile for Django and MongoEngine Supports: PostgreSQL SQLite MariaDB MySQL (with an extension) SQL Server MongoDB ?? Uses na

Andrew Kane 4 Jan 15, 2022
Blog focused on skills enhancement and knowledge sharing. Tech Stack's: Vue.js, Django and Django-Ninja

Blog focused on skills enhancement and knowledge sharing. Tech Stack's: Vue.js, Django and Django-Ninja

Wanderson Fontes 2 Sep 21, 2022
This a Django TODO app project and practiced how to deploy and publish the project to Heroku

ToDo App Demo | Project Table of Contents Overview Built With Features How to use Acknowledgements Contact Overview Built With HTML CSS JS Django How

Cetin OGUT 1 Nov 19, 2021