arena view

The arena view accepts the request object and then instantiates an ArenaForm object to gather the data needed to respond to the request. A query of the Arenas model objects and its values_list method creates a Python list that contains tuples with the ID and name of every arenaThe request method (either GET or POST) is used in a conditional to determine the appropriate response.

If a GET request is received (that is, the web page is first opened), a random arena object is generated and passed to the template, which shows the arena on the included map. To get a random arena, we use the list of arena names and IDs (values). Once the list is generated, a list comprehension is used to generate a new list containing arena names.  ...

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.