from django.db import models from django.contrib.contenttypes.models import ContentType class RelatedPost(models.Model): model_name = models.ForeignKey(ContentType, null=True, on_delete=models.SET_NULL) entry_id = models.IntegerField() title = models.CharField(max_length=200) slug = models.CharField(max_length=50) def __str__(self): return self.title