I have 3 table
from django.db import models
from django.contrib.auth.models import User
class Boost(models.Model):
title = models.CharField(max_length=50,null=False)# point, storage, point p/s,
expire = models.BooleanField(default=False)
expireDate = models.DateTimeField(null=True)
visiblity = models.BooleanField(default=True)
def __str__(self):
return "id:"+self.title
class BoostLevel(models.Model):
id = models.AutoField(primary_key=True)
boost = models.ForeignKey(Boost, on_delete=models.CASCADE)
level = models.IntegerField(null=False)
def __str__(self):
return self.boost.title + " level: " + self.level.__str__()
class UserBoostList(models.Model):
boostLevel = models.ForeignKey(BoostLevel, on_delete=models.CASCADE)
boostId = models.ForeignKey(Boost, on_delete=models.DO_NOTHING)
userId = models.BigIntegerField(null=False)
In my case, Boost is a title, Boost level are levels for boost and UserBoostList are User selected boost
Each boost can have many level from 1 to X.
Each user should start boost from level 1 to level 2 to and go on
I need to check each user have which level of boost for each boost
let me explain
I have Boost A and boost B in Boost table
and boosts level 1 ,2 ,3 … for each boost separate, Ex(boost A level 1, boost A level 2 and … AND boost B level 1 , boost B level 2 and …)
Now how can I get info for username like Alex to know which level he boosted for each boost
Note: You can add or remove any field to make module better if you need. but tell me about that.
I try to find best way to get info from 3 table with foreignKey.