Django Inheritance and Permalinks

后端 未结 3 738
孤城傲影
孤城傲影 2021-01-07 05:25

I\'m creating a simple CMS in django, with multiple \"modules\" (each as a django app). I\'ve set up the following models:

class FooObject(models.Model):
            


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-07 06:24

    You can avoid adding a content type field by using the InheritanceManager from django-model-utils.

    Then, if you call .select_subclasses on a queryset, it will downcast all of the objects, for example:

    FooPage.objects.select_subclasses().all()
    

提交回复
热议问题