Answer the question
In order to leave comments, you need to log in
How to display the entire table from the database if None came from the form?
For example, there is this code:
qs = request.GET.post("q") # И значение переменной None
model = Model.objects.filter(name=qs)
model = Model.objects.filter(name=all())
.
Answer the question
In order to leave comments, you need to log in
if
and Model.objects.all()
Let's play guessing games, since in the comments we found out that there are a lot of fields and "shit code", then
model = Model.objects.all()
for field in ['field1', 'field2', 'field3']:
if value := request.GET.get(field):
model = model.filter(**{field: value})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question