Skip to main content

DRF complete autocomplete

Test package Coverage Status

Installation

$ pip install drf-complete-autocomplete
$ pip install drf-complete-autocomplete[django-filter]

How to use

Settings:

from drf_complete_autocomplete.configuration import AutocompleteModelDescription

from my_app.models import MyModel


AUTOCOMPLETE_MODELS = [
    AutocompleteModelDescription(
        api_name='my_model',
        model=MyModel,
        value_field='pk',
        label_field='__unicode__',
        icontains_search_fields=['name'],
        filterset=None,  # django-filter FilterSet
        order_by=['name'],
        distinct=False,
        results_limit=20,
    ),
]

Serializer:

...
from drf_autocomplete.serializers import WithAutocomplete
...


class SomeModelSerializer(WithAutocomplete, serializers.ModelSerializer):
    ...

    class Meta:
        model = SomeModel
        fields = [
            ...
            'related_to_my_model',
            ...
        ]
        ...
        autocomplete_fields = {
            'related_to_my_model': 'my_model',
        }

View:

You can import drf_complete_autocomplete.views.RetrieveAutocompleteResultsApiView and supply your AUTOCOMPLETE_MODELS in urls file RetrieveAutocompleteResultsApiView.as_view(autocomplete_config=AUTOCOMPLETE_MODELS).

Or use mixin drf_complete_autocomplete.views.RetrieveAutocompleteResultsMixin to create your own view.

License

The DRF complete autocomplete package is licensed under the FreeBSD License.

Release files for drf-complete-autocomplete 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-complete-autocomplete 1.0.0
File Size Uploaded
drf-complete-autocomplete-1.0.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drf-complete-autocomplete 1.0.0
File Interpreter ABI Platform
drf_complete_autocomplete-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size:12.5 kB

Release files / drf-complete-autocomplete-1.0.0.tar.gz

Download URL drf-complete-autocomplete-1.0.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e58ccda6313b82eeec6f7d36883b60d0b7d7c33aa6eefa12993e301abbdab689
BLAKE2b-256 checksum
How to use checksums
db4b1f73608a96912d3dda10f3a6620b1c98489b517a0fc7ebd0e34dfa098013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / drf_complete_autocomplete-1.0.0-py3-none-any.whl

Download URL drf_complete_autocomplete-1.0.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
803d6d37ebf2035db5542ce92012e0845c35db9df0d1552145e55f2c8ac153e8
BLAKE2b-256 checksum
How to use checksums
82173e42f60a2e0605ad7023af7684aa4666bde957c5b200ed67afdb2c6bf6eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page