django - OneToOneField QuerySet returning empty dict -
i have 2 models called manufacturer , car . car model has foreignkey manufacturer mean many cars can belong single manufacturer. in model manfacturer , onetoonefield called showcase allows manufacturer have single car showcase, how can show manufacturers have car showcase mean , show manufacturer onetoonefield objects.
i tried manufacturer.objects.filter(showcase=true) return empty dictionary []
class manufacturer(models.model): user = models.foreignkey(user) name = models.charfield(max_length=55) showcase = models.onetoonefield('car',related_name='car',blank=true) class car(models.model): user = models.foreignkey(user) manufacturer = models.foreignkey(manufacturer,blank=false,related_name='manufacturer')
try manufacturer.objects.exclude(showcase=none)
also, in model try add null=true
next to blank=true
in showcase attribute of model.
Comments
Post a Comment