Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django genericforeignkey null

class MyModel(models.Model):
    ...other fields...
    content_type = models.ForeignKey(ContentType, blank=True, null=True, on_delete=models.SET_NULL)
    object_id = models.PositiveIntegerField(blank=True, null=True)
    content_object = generic.GenericForeignKey('content_type', 'object_id')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #genericforeignkey #null
ADD COMMENT
Topic
Name
3+2 =