Creating model and views

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jiraka7
    New Member
    • Apr 2022
    • 1

    Creating model and views

    I would need help creating models and views for my project. I need a model that will extend the auth.user model that I use to authorize users. There should also be three int columns, game1-score, game2-score, and game3-score, in this model, into which I will insert data using views. I need to make sure that the logged-in user is found in views and then find out if his record already exists in the created model and insert the score into the correct column using the value game_id, which also comes with a score to views, and if the column already has a value he has to compare it with the new one and save the bigger one.

    I would really appreciate the help, especially with the views part, I have a model created somehow, but I don't know if well, see below.

    Code:
    models.py
    class UserGameScore(models.Model):
        user_rec = models.ForeignKey(User, on_delete=models.CASCADE)
        
        game1_score = models.IntegerField(null=True, blank=True)
        game2_score = models.IntegerField(null=True, blank=True)
        game3_score = models.IntegerField(null=True, blank=True)
    Last edited by zmbd; Apr 13 '22, 02:39 AM. Reason: added code tags
Working...