设备型号:
class Devices(AbstractFCMDevice):
user = models.ForeignKey('User', on_delete=models.CASCADE)
JobTags模型:
class JobTags(models.Model):
name = models.CharField(max_length=40, blank=True, null=True) # Name of the tag
job_base_rate = models.DecimalField(decimal_places=2, max_digits=10, blank=True, null=True) # Amount we take to escrow before a job begins
job_unit_rate = models.DecimalField(decimal_places=2, max_digits=10, blank=True, null=True) # Rate per unit
unit = models.CharField(max_length=50, blank=True, null=True) # Name of the unit
providers = models.ManyToManyField(User)
用户模型:
class User(AbstractBaseUser):
email = models.EmailField(unique=True)
password = models.CharField(max_length=200)
REQUIRED_FIELDS = ['password']
USERNAME_FIELD = 'email'
objects = UserManager()
实际导致错误的代码行:
device = Devices.objects.filter(user__jobtags__name__contains=name)
我遇到的实际错误...
AttributeError: 'Devices' object has no attribute 'providers'
我觉得...当然,设备没有一个称为提供者的字段...但是我的过滤器在做什么错了?
由于某种原因,代码并没有停止运行,实际上可以运行并完成我需要的操作,但是它仍然给我500错误...这确实很奇怪。
我的过滤器查询不正确吗?显然,但是有更好的方法吗?