Esempio n. 1
0
    def __init__(self, model, search_fields=None, url_name=AUTOCOMPLETE_URL_NAME, attrs=None):
        if hasattr(model, 'to'):
            # This is a relation manager 
            self.model = model.to
        else:
            self.model = model

        self.search_fields = search_fields
        self.url_name = url_name

        if (search_fields):
            # Allow these fields (for this model) to be searched 
            add_searchable_fields(self.model, self.search_fields)

        super(AutocompleteSelectMultiple, self).__init__(attrs)
Esempio n. 2
0
    def __init__(self, model=None, search_fields=None, url_name=AUTOCOMPLETE_URL_NAME, attrs=None):

        if model is None:
            if hasattr(settings, 'AUTOCOMPLETE_TAG_MODEL'):
                model = get_model(*settings.AUTOCOMPLETE_TAG_MODEL.split('.', 2))
            else:
                raise ImproperlyConfigured("AUTOCOMPLETE_TAG_MODEL setting not set. Set it to the name of the tag model to autocomplete.")

        self.model = model
        self.search_fields = search_fields
        self.url_name = url_name

        if (search_fields):
            # Allow these fields (for this model) to be searched 
            add_searchable_fields(self.model, self.search_fields)

        super(AutocompleteTag, self).__init__(attrs)
Esempio n. 3
0
    def __init__(self,
                 model,
                 search_fields=None,
                 url_name=AUTOCOMPLETE_URL_NAME,
                 attrs=None):
        if hasattr(model, 'to'):
            # This is a relation manager
            self.model = model.to
        else:
            self.model = model

        self.search_fields = search_fields
        self.url_name = url_name

        if (search_fields):
            # Allow these fields (for this model) to be searched
            add_searchable_fields(self.model, self.search_fields)

        super(AutocompleteSelectMultiple, self).__init__(attrs)
Esempio n. 4
0
    def __init__(self,
                 model=None,
                 search_fields=None,
                 url_name=AUTOCOMPLETE_URL_NAME,
                 attrs=None):

        if model is None:
            if hasattr(settings, 'AUTOCOMPLETE_TAG_MODEL'):
                model = get_model(
                    *settings.AUTOCOMPLETE_TAG_MODEL.split('.', 2))
            else:
                raise ImproperlyConfigured(
                    "AUTOCOMPLETE_TAG_MODEL setting not set. Set it to the name of the tag model to autocomplete."
                )

        self.model = model
        self.search_fields = search_fields
        self.url_name = url_name

        if (search_fields):
            # Allow these fields (for this model) to be searched
            add_searchable_fields(self.model, self.search_fields)

        super(AutocompleteTag, self).__init__(attrs)