I have made a Django/jQuery/JS Tug O' War app in which users button mash their specific key in attempts to pull the HTML <img>
tag all the way to their side of the screen. When a user wins, The Game/Player model fields are updated and the game starts over. Some of those fields are total amount of key presses it took to win the game, who won/lost, and how many wins/losses each player has.
The project I am working on asks that I create a new Django endpoint for leaderboards that display some simple game statistics.
What is a Django endpoint?
Is it just a fancy word for making a normal leader board? Or am I suppose to do something special? They suggest that I use Mustache while making it (can't find much of an explaination about what that is either).
I cannot seem to find relevant information on Stack Overflow or the interwebs. At this point I have been searching for an answer for about 2 hours.
Here is a link to the project instructions..
Tug O' War
First, a few resources: read more about API endpoints in this previous blog post and review documentation on Django Rest Framework. A typical request for an API endpoint may be something like: 'the front end app needs to be able to read, create, and update companies through the API'.
Why Django Rest Framework? What is an API? Django Rest Framework lets you create RESTful APIs: A way to transfer information between an interface and a database in a simple way. It separates user interface and data storage and communicates user and database sending a .json file.
In order to use Django-specific APIs, you must configure them into the environment. For example, you can create myproject/jinja2.py with this content: and set the 'environment' option to 'myproject.jinja2.environment'. Then you could use the following constructs in Jinja2 templates:
The Django template language is Django’s own template system. Until Django 1.8 it was the only built-in option available. It’s a good template library even though it’s fairly opinionated and sports a few idiosyncrasies.
It seems they expect to create an API to send data to javascript, then using a templating engine like mustache
, you create a leader page.
The master keyword here is : ajax.
Display the leaderboards on the bottom of your game page. Use AJAX to load each leaderboard on game start. It should update when the game is finished, and the last game played should be present if applicable.
When someone need you to do a work using ajax, that means you need to server data only from the server and handle remains in UI.
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