C
C
Cross58202020-07-15 16:54:51
Django
Cross5820, 2020-07-15 16:54:51

Django how to combine select and TextInput?

Good day! Relatively recently, I started learning Django and now I ran into a problem that I can’t solve in any way.
I have a formset associated with a model.

The form itself:

class typeblockcompform(forms.ModelForm):
    class Meta:
        model = Тип_блока_компонент
        fields = ('id', 'Тип_блока', 'Компонент')
        widgets = {
            'Тип_блока': forms.widgets.HiddenInput(),
        }

And here is the formset itself:
blockcompformset = modelformset_factory(Тип_блока_компонент, form=typeblockcompform, can_delete=True)


The shapeset is needed to bind components to block types.
The essence of the problem is that the "Component" field has the Select type in html.
Accordingly, from a great variety of components, it becomes problematic to find the right one.
How can I change the type of the field so that there is an input string along with the select?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Belokurov, 2020-07-16
@Cross5820

Use custom widget in template like https://selectize.github.io/selectize.js/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question