Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Note that this is untested.
- models.py:
- class Title(models.Model):
- title = models.CharField("Title", max_length=200)
- content_type = models.ForeignKey(ContentType)
- object_id = models.PositiveIntegerField()
- content_object = generic.GenericForeignKey("content_type", "object_id")
- class Meta:
- unique_together = ['content_type', 'object_id']
- class Category(models.Model):
- def get_title(self):
- return Title.objects.get(content_type=self.__class__, object_id=self.id)
- admin.py:
- class TitleInline(generic.GenericTabularInline):
- model = Title
- class CategoryAdmin(admin.ModelAdmin):
- inlines = [TitleInline]
- admin.site.register(Category, CategoryAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement