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 Girls Tutorial Workshop

Django Girls Tutorial Workshop A log of activities during the workshop. this is an H2 git remote add origin https://github.com/ahuimanu/django_girls_t

Jeffry Babb 1 Oct 27, 2021
Django With VueJS Blog App

django-blog-vue-app frontend Project setup yarn install Compiles and hot-reload

Flavien HUGS 2 Feb 04, 2022
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
Getdp-project - A Django-built web app that generates a personalized banner of events to come

getdp-project https://get-my-dp.herokuapp.com/ A Django-built web app that gener

CODE 4 Aug 01, 2022
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
Hello world written in Django.

Learning Django 💡 create a virtual environment create python -m venv ./venv. this virtualenv file will be excluded by .gitignore activate the virtual

Dipak giri 4 Nov 26, 2021
A Django based shop system

django-SHOP Django-SHOP aims to be a the easy, fun and fast e-commerce counterpart to django-CMS. Here you can find the full documentation for django-

Awesto 2.9k Dec 30, 2022
Compresses linked and inline javascript or CSS into a single cached file.

Django Compressor Django Compressor processes, combines and minifies linked and inline Javascript or CSS in a Django template into cacheable static fi

2.6k Jan 03, 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
Django CRUD REST API Generator

Django CRUD REST API Generator This is a simple tool that generates a Django REST API with the given models. Specs: Authentication, DRF generic views,

Mehmet Alp Sümer 57 Nov 24, 2022
Let AngularJS play well with Django

django-angular Let Django play well with AngularJS What does it offer? Add AngularJS directives to Django Forms. This allows to handle client side for

Jacob Rief 1.2k Dec 27, 2022
Django React Project Setup

Django-React-Project-Setup INSTALLATION: python -m pip install drps USAGE: in your cmd: python -m drps Starting fullstack project with Django and Reac

Ghazi Zabalawi 7 Feb 06, 2022
A simple REST API to manage postal addresses, written in Python/Django.

A simple REST API to manage postal addresses, written in Python/Django.

Attila Bagossy 2 Feb 14, 2022
Exemplo de biblioteca com Django

Bookstore Exemplo de biblioteca feito com Django. Este projeto foi feito com: Python 3.9.7 Django 3.2.8 Django Rest Framework 3.12.4 Bootstrap 4.0 Vue

Regis Santos 1 Oct 28, 2021
Django Fett is an incomplete code generator used on several projects

Django Fett Django Fett is an incomplete code generator used on several projects. This is an attempt to clean it up and make it public for consumption

Jeff Triplett 6 Dec 31, 2021
An API was build with Django to store and retrieve information about various musical instruments.

The project is meant to be a starting point, an experimentation or a basic example of a way to develop an API with Django. It is an exercise on using Django and various python technologies and design

Kostas Ziovas 2 Dec 25, 2021
Strawberry-django-plus - Enhanced Strawberry GraphQL integration with Django

strawberry-django-plus Enhanced Strawberry integration with Django. Built on top

BLB Ventures 138 Dec 28, 2022
Automatic class scheduler for Texas A&M written with Python+Django and React+Typescript

Rev Registration Description Rev Registration is an automatic class scheduler for Texas A&M, aimed at easing the process of course registration by gen

Aggie Coding Club 21 Nov 15, 2022
A Django/Python web app that functions as a digital diary

My Django Diary Full-stack web application that functions as a digital diary using Django, Python, SQLite, HTML & CSS. Things I learned during this pr

1 Sep 30, 2022
Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield Description: Django Audio Management Tools Maintainer: Areski Contributors: list of contributors Django-Audiofield is a simple app t

Areski Belaid 167 Nov 10, 2022