DJango-tables2 how do I refresh/update the table on the webpage without hitting refresh button - django

I followed the DJango-tables2 official tutorial and was able to create data set in the terminal using:
Person.objects.bulk_create([Person(name='Jieter'), Person(name='Bradley')])
However, the new data in the table on the website doesn't show up until I hit the refresh button. My question is how the table can be updated/refreshed without any human interaction on the webpage.
What I'm trying to achieve is to update the table on the webpage without human interaction as soon as new data comes in. I'm relatively new to this, any suggestions would be greatly appreciated.
Thank you.

To avoid refreshing the page you would need to get new data using an Ajax request, this table use template rendering meaning it is not meant to work like you want to use it.
Usually, to do what you want to do, you need a front end JavaScript component like Datatables.net, FancyGrid ... and make requests to server using Ajax to get new data.

Related

Oracle Apex Event when page gets changed with custom attributes in plugin

I am currently trying to develop a plugin in oracle apex. This plugin consists of attributes which have SQL queries. I want to pass this SQL queries into the child component. In this case the child component is a dialog window.
I can pass different values like numbers or strings easily as page items with the url approach. However using this approach is not very scalable because of the URL restriction of maximum 2000 characters.
e.g. with APEX_UTIL.PREPARE_URL
Therefore I thought of storing SQL-Queries in the database and then query it in the dialog.
And here is the problem: How can I store the SQL Queries when the plugin is configured?
I do not like to have the logic in the render call, because this way everytime the plugin gets rendered it makes some unnecessary database requests.
Is there something like an event when the page gets saved with the plugin? Or a possibility to have some PL/SQL code after the page gets changed which can access the plugin attributes?

How to disable ember-fastboot after site already loaded locally?

This is related to a post I recently made regarding ember-fastboot and saving a webpage for offline viewing.
I am making a separate post because I believe this is more an ember-fastboot question and isn't specific to the website I am trying to save for offline viewing.
Basically, I am trying to find out how, on the local end, to completely override ember. That is, since I already have open in my browser the rendered page, what does one need to do in order to save the page such that when opened later locally as offline page, the page appears the same way it did when rendered in the first place?
It seems like I am in a paradox. I have a rendered page, with content such as a javascript media player. I save rendered page. I then open the locally saved, rendered page but then the ember javascript kicks in and alters the page, such that the javascript media player no longer loads, due to ember altering a div's class name to specify that the player is not booted! The thing is, once rendered, I don't need ember doing anything, as I am just interested in viewing a frozen copy of the rendered page with no interest in subsequent connections to the rendering server.
Anyway, hope someone can shed some light on this.
Thanks!
You could remove <script> tags from the index.html after saving it. That would prevent the app from starting, leaving the pre-rendered HTML intact.
You might need to split the JS bundle if you need a JS player to be running independently. Splitting the bundle is an advanced technique. If you need it, please ask a separate question.

Django page update no ajax or comet

I'm making a small app for internal use between 3 people. the idea is to have a page where user can upload files and data ( more specifically images.) to the database and a second page where the information the user uploaded in the first page will be visible without having to manually refresh the page. I have read about comet and ajax and I think having a function check the Db every certain time is not what I'm looking for. Since there will be almost no updates in the DB. maybe every 3 to 4 months the user might update a new image.
Have a read through at least one good tutorial on ajax & django, it's quite simple once you get started with it. But you can't really achieve this without AJAX.
Take a look at this;
https://simpleisbetterthancomplex.com/tutorial/2016/08/29/how-to-work-with-ajax-request-with-django.html

Django Statelessness

I was reading some blogs and came up to the conclusion that django is an MVT architecture which do not maintain state. I am working on application that have maps visualization. When the user selects a variable from the drop down, a request is sent to the backend database and on the screen, it generates the heat-map of that specific variable.
what I want to achieve is that if I go some other tab and do some other changes like change the layer of map or select some another variable, the state of old heat map should be maintained regardless if I want to clear it. I do not know how to maintain state in django can anyone help me in this?
You can leverage the Django's sessions mechanism. You'll need an AJAX request that POSTs the current tab state to Django, so your backend code can restore it on page reload.

Reload googlemaps after user clicks a link in Django

I am doing a project in Django and i want to have some google maps displayed in my site. So, i installed django-easy-maps and successfully used it in a sample template. So, i am ready with my maps.
The interface i want to implement is this
http://i49.tinypic.com/sowm74.png
I want to display the maps where the Hellow World! container is and with different links on the sidebar i want to refresh the map being displayed on user click without reloading the page.
I did some researching and it seems Ajax is the solution...
Can anybody tell me how i might achieve this (with or without Ajax ) ?
Sorry for sounding like a noob but i am fairly new to this.
The basic steps are:
Create a view for the Google Maps section to the right. This view does not return a full HTML page but only the HTML for that section (which contains your Google Maps map).
When the user clicks on a link on the left, use JavaScript to perform an ajax call to request that page. In short this means: attach an event handler to the onclick event of those links and in code you can perform an ajax call .Many people use a JavaScript library for this purpose, such as jQuery (which has $.ajax()).
You can then use JavaScript to put the received HTML inside the container on the right (using $.html()).