470,593 Members | 2,477 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,593 developers. It's quick & easy.

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.

Expand|Select|Wrap|Line Numbers
  1. models.py
  2. class UserGameScore(models.Model):
  3.     user_rec = models.ForeignKey(User, on_delete=models.CASCADE)
  4.  
  5.     game1_score = models.IntegerField(null=True, blank=True)
  6.     game2_score = models.IntegerField(null=True, blank=True)
  7.     game3_score = models.IntegerField(null=True, blank=True)
Apr 8 '22 #1
0 5444

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Droolboy | last post: by
7 posts views Thread by pysim | last post: by
6 posts views Thread by Dim St Thomas | last post: by
1 post views Thread by RJMAL | last post: by
1 post views Thread by kellyj00 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.