V
V
Vitaly Ananiev2022-01-08 15:26:15
Django
Vitaly Ananiev, 2022-01-08 15:26:15

How to pass slug to forms.py?

Is there a form like this, how can I pull the slug from views and pass it to forms.py ?

forms.py

class AddAvailabilityForm(forms.Form):
    
    servers = forms.ModelChoiceField(queryset=Servers.objects.filter(id_num=slug)) - как сюда передать слаг

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-01-08
@Vitalii181190

how to pass slug here
right here, no way. And in the last question you were told how to do it through name
Let's turn on your brains already, and don't run here for every sneeze. The slug is known in views, so you need to redefine the place where the form is created, pass your slug to the forms and filter servers inside it, and not here at the description stage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question