django genericforeignkey null code example
Example: 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')