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
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
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 909 Dec 26, 2022
Basic implementation of Razorpay payment gateway 💳 with Django

Razorpay Payment Integration in Django 💥 In this project Razorpay payment gateway 💳 is integrated with Django by breaking down the whole process int

ScaleReal 12 Dec 12, 2022
Django based webapp pulling in crypto news and price data via api

Deploy Django in Production FTA project implementing containerization of Django Web Framework into Docker to be placed into Azure Container Services a

0 Sep 21, 2022
Exploit Discord's cache system to remote upload payloads on Discord users machines

Exploit Discord's cache system to hide payloads PoC Remote upload embedded payload from image using EOF to Discord users machines through cache. Depen

cs 169 Dec 20, 2022
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
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
A BitField extension for Django Models

django-bitfield Provides a BitField like class (using a BigIntegerField) for your Django models. (If you're upgrading from a version before 1.2 the AP

DISQUS 361 Dec 22, 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
Log and View requests made on Django

Django Request Viewer Log and view requests made on your Django App Introduction Recently, @ichtrojan and @toniastro released horus, a request logger

Akere Mukhtar 26 May 29, 2022
Add Chart.js visualizations to your Django admin using a mixin class

django-admincharts Add Chart.js visualizations to your Django admin using a mixin class. Example from django.contrib import admin from .models import

Dropseed 22 Nov 22, 2022
Django With VueJS Blog App

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

Flavien HUGS 2 Feb 04, 2022
An insecure login and registration website with Django.

An insecure login and registration website with Django.

Luis Quiñones Requelme 1 Dec 05, 2021
Projeto onde podes inserir notícias, ver todas as notícias guardas e filtrar por tag. A base de dados usada é o mongoDB.

djangoProject Projeto onde podes inserir notícias, ver todas as notícias guardas e filtrar por tag. A base de dados usada é o mongoDB. packages utiliz

Sofia Rocha 1 Feb 22, 2022
This is a basic Todo Application API using Django Rest Framework

Todo Application This is a basic Todo Application API using Django Rest Framework. Todo Section - User can View his previously added todo items, creat

Atharva Parkhe 1 Aug 09, 2022
GameStop clone with Django

GameStop clone with Django This is my side project with GameStop clone Author: HackerApe GitHub Profile: View Profile LinkedIn Profile: View Profile

Dmitriy Shin 2 Dec 26, 2021
System checks for your project's environment.

django-version-checks System checks for your project's environment. Requirements Python 3.6 to 3.9 supported. Django 2.2 to 3.2 supported. Are your te

Adam Johnson 33 Dec 22, 2022
Automatically reload your browser in development.

django-browser-reload Automatically reload your browser in development. Requirements Python 3.6 to 3.10 supported. Django 2.2 to 4.0 supported. Are yo

Adam Johnson 254 Jan 04, 2023
Example project demonstrating using Django’s test runner with Coverage.py

Example project demonstrating using Django’s test runner with Coverage.py Set up with: python -m venv --prompt . venv source venv/bin/activate python

Adam Johnson 5 Nov 29, 2021
Simple application TodoList django with ReactJS

Django & React Django We basically follow the Django REST framework quickstart guide here. Create backend folder with a virtual Python environment: mk

Flavien HUGS 2 Aug 07, 2022