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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With