How to set multiple ParentalKeys to Wagtail TaggedItemBase tag class

后端 未结 1 1460
青春惊慌失措
青春惊慌失措 2020-12-20 05:51

I have two different page models (no subclassing, separate apps with only similar fields being common ones like \"model name\", \"id\", \"parts\") , let\'s say, cars and mot

相关标签:
1条回答
  • 2020-12-20 06:11

    Setting up separate CarPageTag and BikePageTag models is the solution you want (assuming they're subclasses of TaggedItemBase, as per the pattern shown in the Wagtail documentation).

    TaggedItemBase is not a tag model itself - it just defines the relation between the page model and the tag model (which, in this case, is taggit.Tag, the standard tag model provided as default by the django-taggit library). Therefore, CarPageTag is setting up a relation between CarPage and taggit.Tag, and BikePageTag is setting up a relation between BikePage and taggit.Tag - both are using the same tag model.

    If you did want cars and bikes to maintain their own independent set of tags, you'd need a different pattern - custom tag models.

    0 讨论(0)
提交回复
热议问题