Answer the question
In order to leave comments, you need to log in
How to organize dynamic display of data from the database in django?
There is a task - to dynamically display data from the help base of the drop-down list.
(In the case of php, this is pretty easy to do with an ajax request.)
Is there a basic way in django to solve this?
Answer the question
In order to leave comments, you need to log in
JsonResponse
Also useful: csrf ajax
(In the case of php, this is fairly easy to do with an ajax request.)
You can do this:
<p><select name="pr" required id="prepod">
<option selected value="0">Выбрать</option>
{% for prepod in prepods %}
<option value="{{ prepod.pk }}">{{ prepod.name }}</option>
{% endfor %}
</select>
<input type="submit" value="Отправить"></p>
class PrepodForms(forms.ModelForm):
prepodname = forms.ModelChoiceField(queryset = Prepod.objects.all(),
empty_label="Выберите преподавателя",
widget=forms.widgets.Select(attrs={'class':'dropdown'}),label="Преподаватель")
class Meta:
model = Prepod
fields = ()
{{ grform.gruppname }}
<input type="submit" value="Показать расписание">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question