So I have a Leaderboard
page and a Django model such as:
models.py
class Leaderboard(models.Model):
rank = models.IntegerField()
team_name = models.CharField(max_length=100)
score = models.IntegerField()
The thing I'm confused is how can I write the views.py
function so that whenever I make a request and upload a new excel file to the views.py
it would overwrite the old objects inside of the database and fill the database with the new data. I'm not sure if this is the correct way of creating a manual leaderboard but it's the only way I could think of currently.
What I could think of so far:
views.py
def update_leaderboard(request):
new_excel = request.body
data = pd.read_excel(new_excel)
# Overwrite the database here
...
ADDITIONAL INFORMATION
I'm using Django Rest Framework as well in this case, because I'm using React for my frontend. So the views might come out a little different (?)