python - Forcing refresh/reload of url in one browser when url in second browser window is updated -


I have a website that's written using the Django, which contains text entry, voting, and serial listings from age and vote The table is displayed, all on one page:

Now I have to see a separate entry, voting, and table page, and I have started from the polling page. It works well, and votes are added to entries in the built-in sqlite3 database, but I have to manually refresh the table page (index).

Is there an easy way to update, or reload table data in the last resort, the voting URL or actions in the table in the table (index) URLs?

  DIF index (request): reference ========================================================================================== < {'Latest_antry_list': entry.object. Order Bibi ('- pb_date') [: 10], 'High-Entry_list': Entry. Blogs ('- Score', '- pub_date') [: 10], 'High_Tree': Entry.Object. ['] -', 'low_entry_list': Entry.objects ('scores',' - pb_date ') [: 10],' voting_trategi_light ': entry.objects (' '- score', '- pb_date')] Unverified_random (),} return render (request, 'entries / index' html ', references); Def vote (request): voting_id = request.GET.get ('vote') if request.method == 'GET': v = Entry.objects.get (pk = voting_id) v.score + = 1 v.voted = True v.save () Other: HTPRPS ('done')  

voting.html

  & lt; Div id = "vote" square = "high" & gt; & Lt; Div style = "text-align: center" & gt; To enter {% Voting_entry_list%} & lt; Li & gt; & Lt; A href = "/ entries / {{entry.id}} /" & gt; {{Entry} text}} & amp; {{Entry.score}} & lt; / A & gt; & Lt; / Li & gt; & Lt; P & gt; & Lt; Input type = "submit" id = "voteid" name = 'voteid' value = "{{entry.id}}" autofocus value = "" onfocus = "this.value = this.value;" Class = "transparent" /> & Lt; Script & gt; Bind ("keydown", function (e) {// input type = ID above (if e.keyCode == 38) {var text = $ ("# Voteid"). Val (); var args = {'voteid': text}; $ .get ("/ voteup /", args) .done (function) {console.log ("Message: "+ Data); location .reload ();}); return false;}});}); & Lt; / Script & gt; {% Endfor%} & lt; / Div & gt;     


Edit for code based on approved answer;

Thank you, I took my first option and I did it on the table page:

  & lt; Script & gt; SetTimeout (function () {$ .ajax ({url: "", reference: document.body, success: function (s, x) {$ (this) .html (s);}});}, 1000); & Lt; / Script & gt;  

What is the last resort to update, or last resort, Reload table data in table of contents (URL) from action in voting URL or ideas?

One way to automatically check the browser is to update yourself from back end, and then update yourself without "refreshing".

How notifications work on this stack overflow

You have two options to complete it:

  1. If you receive a new message Do you change or change your reputation,

    You can choose the database of each x second from the end of your front, and then you can trigger an update, basically There is an automatic way to kill "F5".

  2. You can open the socket so that your front end updates when the backend is updated.

Either way you will need to add some front end logic. For the # 2 option, you can use the app which is a way to open the socket to use the library (it looks like a permanent connection), between the browser and the backend .

At the end of the back you create a channel, on which you will broadcast the message. Browsers will subscribe to these channels and listen. As soon as the message is transmitted from your backend, the browser can trigger an update (for example, add a new line to the table, warn, popup popup)


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -