How to auto refresh admin page on browser after data have changed on server?

3.2k Views Asked by At

I want to auto refresh the admin page on browser after a specific model on the database changes. Is it possible to do that?

To be more clearly: I want to refresh the url .../admin/restaurants/orders/ that is already opened on the browser, after the user posts a new order.

1

There are 1 best solutions below

1
On BEST ANSWER

You can send ajax request (do it in your custom js file) to same url == window.location.href (for example every 10 seconds)

class OrderAdmin(admin.ModelAdmin):
    class Meta:
        model = Order
    class Media:
        js = ("my_code.js",)

Useful links:

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#modeladmin-asset-definitions

http://www.w3schools.com/jquery/ajax_ajax.asp

http://api.jquery.com/jquery.ajax/