Using Django and I would like to change the order of the display of the objects on click without refreshing the page.
my model
class IndexView(generic.ListView):
template_name = 'movies/index.html'
page_template = 'movies/all_movies.html'
context_object_name = 'all_movies'
model = Movie
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
context.update({
'all_genres': Genre.objects.all(),
'our_pick': Movie.objects.get(pk=259)
})
return context
def get_queryset(self):
return Movie.objects.all()
And this is my index.html
<menu class="menu">
<ul>
<li><a href="#">Newest</a></li>
<li><a href="#">Most Popular</a></li>
</ul>
</menu>
on clink on Newest, the query will become:
Movie.objects.all().order_by('release_date')
and on click on Most popular, the query will become:
Movie.objects.all().order_by('popularity')
How can I achieve that without refreshing the page? any help would be appreciated!