Skip to main content

Simplify autocomplete functionalities implementation in your Django project.

Project description

Django Sweet Autocomplete

The purpose of Sweet Autocomplete is to simplify autocomplete functionalities implementation in your Django project.

Quick start

  1. Add "sweetautocomplete" to your INSTALLED_APPS setting::
INSTALLED_APPS = [
    ...
    'sweetautocomplete',
]
  1. Include the autocomplete URLconf in your project urls.py:
urlpatterns = [
    ...
    path("", include("sweetautocomplete.urls")),
    ...
]
  1. Create a file called autocomplete.py in your app:
from sweetautocomplete.autocomplete import autocompletefactory, AbstractAutocomplete
from .models import MyModel

class MyModelAutocomplete(AbstractAutocomplete):
    model = MyModel
    field = "field_name"

    class Serializer(serializers.ModelSerializer):
        label = serializers.CharField(source="field_name")

        class Meta:
            model = MyModel
            fields = ["label"]


autocompletefactory.register("model_name", MyModelAutocomplete)
  1. Use autocomplete endpoints in your templates:
"{% url 'autocomplete' 'model_name' %}?query=..."

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sweet-autocomplete-1.0.2.tar.gz (3.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page