I would do something simitar to:
class SongListView(ListView):
model = Song
context_object_name = 'songs'
template_name = 'songs/song_list.html'
def get_queryset(self):
qs = super().get_queryset()
name = self.request.get("name")
if name:
qs
Hi,
"Is it safe"? Well that is your call to make. Depending number of songs it
might not be meanful for enduser to see whole list which leads to things
like pagination and restricting maximum number of returned entries.
On Sun, Feb 25, 2018 at 8:10 AM, tango ward wrote:
thanks for the suggestions Ken. I just want to ask too if it's safe to
display the list of songs even if the textbox is empty?
On Sun, Feb 25, 2018 at 10:21 AM, Ken Whitesell
wrote:
> One of the issues is here:
> if request.method == 'GET':
>
One of the issues is here:
if request.method == 'GET':
song_name = request.GET.get('name', "Error")
songs = self.model.objects.filter(name__icontains=song_name)
else:
songs = self.models.all()
return render(request, self.template_name,
Hi,
I am playing around on adding a search feature to a website. I am currently
encountering a problem when the page should load a list of songs and after
typing in a song title in the search box:
views.py
class SongListView(ListView):
model = Song
context_object_name = 'songs'
5 matches
Mail list logo