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 = SongOne
context_object_name = 'songs'
template_name = 'songs/song_list.html'
def get(self, request, *args, **kwargs):
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, {'songs': songs})
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fee7baf6-7dbe-4a33-a281-f7c8600f73cc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA6wQLK03p7hofrCRAGYQsUxo4NuYddTN5e3rmmOdrUSV-uOUQ%40mail.gmail.com.