问题
My goal is to build a python/django based dashboard related to soccer where the user can select a soccer team of his choice in the sidebar and then gets all related data displayed in the dashboard in return. The dashboard will mostly consist of simple figures and more dynamic charts (using Plotly etc.). I attached the html frontend so you can get a brief feeling of how it will look like.
As for the backend, I am not quiet sure what might be a good or even the best solution structurewise. I hope to get some input/opinions from the community to derive a good approach for my further steps.
I inserted numbers to the questions for the sake of clarity ;).
Templates/Applications
Since the web application will contain one main site (= the dashboard) I prefer to mainly work with a single template (index.html, obviously besides "about" and "blog" sites which will be separated applications).
[1.1] Is there any good reason to maybe split the sidebar and the dashboard parts into two templates?
[1.2] Or even to create a single template for each "part" of the dashboard (Like one template for each single information container)?
Views
As I understand from different tutorials/documentations you usually just use one views.py file in a web application. I will grab the soccer data from an external API using AJAX on "sidebar click" event.
[2.1] Do you recommend to create single view functions for every information container of the dashboard?
[2.2] Or is it good advice to make less views that processes more data/more information containers at a time? (The dashboard will contain around 400 variables).
Urls
I am not sure how to manage all of the functions. Since the user will always request the same url, I will have to map all of the view functions to the same url, no matter which teamm he selects (I don't want the website to reload after a new team was selected). Although, the functions themselves will stay the same apart from the different team_id to fetch the right data from the API.
That being said, the web application/dashboard will more or less be static in terms of multiple sites etc., thus I plan to always refer to the very same url and not to /home/selectedteam. (apart from "About" and "Blog" sites obviously).
[3] Any approach advised on that issue?
Caching
I plan to implement a proper caching environment since the API calls are limited and users might jump between the teams quickly and therefor request the very same data again and again (the data doesn't change very quickly at all).
[4] Are there any concerns about implementing a caching environment in such project?
Else
[5] How to best implement the API calls? Use AJAX in javascript and forward the data to the Python views or directly fetch API data within the Python views (I don't want the user to reload the dashboard each time he selects a different team)?
Right now my approach is to grab the team-id (html attribute) via javascript whenever the user clicks on a team in the sidebar and use this ID via AJAX to make the API calls with a Django view.
[6] Do you have any other topics to consider when developing Django based dashboards? (I decided to use a Python based approach to develop the web application since I will have to use Plotly and other libraries to build dynamic charts using the API data).
Thank you for your answers in advance - much appreciated.
来源:https://stackoverflow.com/questions/58154408/how-to-concept-a-web-application-dashboard-made-of-django-in-terms-of-backend