我有一个类似这样的设备的基本模型:
class device(models.Model):
brand = models.CharField(max_length=200, blank=False)
name = models.CharField(max_length=200, blank=False)
available = models.BooleanField(default=False)
,我想为每个可用设备的每个用户创建一个模型条目:
class userDevice(models.Model):
user = models.ForeignKey(User,related_name='userdevices')
#create an entry for each device which field 'available' is true
#add an extra boolean field 'activate' for each entry above