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
django-tables2 - An app for creating HTML tables

django-tables2 - An app for creating HTML tables django-tables2 simplifies the task of turning sets of data into HTML tables. It has native support fo

Jan Pieter Waagmeester 1.6k Jan 03, 2023
An URL Shortener with Basic Features.

Simple Url Shortener What is that? Yet another url shortener built with Django framework. Preview HOW TO RUN? 1. Virtual Environment First create a vi

Ethem Turgut 6 Jan 25, 2022
GeoDjango provides geospatial extensions to the Django web dev framework

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. All documentation is in the "docs" directo

Paul Smith 20 Sep 20, 2022
Django-Docker - Django Installation Guide on Docker

Guía de instalación del Framework Django en Docker Introducción: Con esta guía p

Victor manuel torres 3 Dec 02, 2022
A simple porfolio with Django, Bootstrap and Sqlite3

Django Portofolio Example this is a basic portfolio in dark mode Installation git clone https://github.com/FaztWeb/django-portfolio-simple.git cd djan

Fazt Web 16 Sep 26, 2022
Packs a bunch of smaller CSS files together from 1 folder.

Packs a bunch of smaller CSS files together from 1 folder.

1 Dec 09, 2021
📝 Sticky Notes in Django admin

django-admin-sticky-notes Share notes between superusers. Installation Install via pip: pip install django_admin_sticky_notes Put django_admin_sticky_

Dariusz Choruży 7 Oct 06, 2021
E-Commerce Platform

Shuup Shuup is an Open Source E-Commerce Platform based on Django and Python. https://shuup.com/ Copyright Copyright (c) 2012-2021 by Shuup Commerce I

Shuup 2k Jan 07, 2023
A Django app for working with BTCPayServer

btcpay-django A Django app for working with BTCPayServer Installation pip install btcpay-django Developers Release To cut a release, run bumpversion,

Crawford 3 Nov 20, 2022
Ugly single sign-on for django projects only

django-usso Ugly single sign-on for django projects only. Do you have many django apps with different users? Do you want to use only one of those apps

Erwin Feser 1 Mar 01, 2022
A simple trivia quizzz web app made using django

Trivia Quizzz A simple trivia quizzz web app made using django Demo http://triviaquizzz.herokuapp.com/ & https://triviaquiz.redcrypt.xyz Features Goog

Rachit Khurana 2 Feb 10, 2022
Djangoblog - A blogging platform built on Django and Python.

djangoblog 👨‍💻 A blogging platform built on Django and Python

Lewis Gentle 1 Jan 10, 2022
Django Federated Login provides an authentication bridge between Django projects and OpenID-enabled identity providers.

Django Federated Login Django Federated Login provides an authentication bridge between Django projects and OpenID-enabled identity providers. The bri

Bouke Haarsma 18 Dec 29, 2020
TinyApp - A Python (Django) Full Stack Application for shortening URLs

TinyApp A Python (Django) Full Stack Application for shortening URLs. How to sta

Li Deng 1 Jan 23, 2022
Template for Django Project Using Docker

You want a Django project who use Docker and Docker-compose for Development and for Production ? It's for you !

1 Dec 17, 2021
Quick example of a todo list application using Django and HTMX

django-htmx-todo-list Quick example of a todo list application using Django and HTMX Background Modified & expanded from https://github.com/jaredlockh

Jack Linke 54 Dec 10, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

10.1k Jan 08, 2023
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 10k Dec 31, 2022
Yet another Django audit log app, hopefully the simplest one.

django-easy-audit Yet another Django audit log app, hopefully the easiest one. This app allows you to keep track of every action taken by your users.

Natán 510 Jan 02, 2023
A pluggable Django application for integrating PayPal Payments Standard or Payments Pro

Django PayPal Django PayPal is a pluggable application that integrates with PayPal Payments Standard and Payments Pro. See https://django-paypal.readt

Luke Plant 672 Dec 22, 2022