[Answer]-Django template not refreshing when using python requests API client

1๐Ÿ‘

โœ…

You are using ListView incorrectly. You assign queriset attribute with something that is not a QuerySet. This means that you fetch the data only once (at the moment of importing the views.py).

Every time when the request to the view comes it uses the data in the queryset attribute. If you want to fetch new data on every request you need to overwrite get_queryset method. Something like:

class ContainerList(ListView):
    template_name = 'containers.html'

    def get_queryset(self):
        return container_list()

This will fetch the data on every request.

๐Ÿ‘คVStoykov

0๐Ÿ‘

If I remember correctly, you will need a signal processor to watch for changes, and when it notices a change, it will update via an AJAX call to the template, replacing with new data.

๐Ÿ‘คRoninDusette

Leave a comment