python - Alternative to django concrete inheritance -


i have django model class encompass various types of model classes like:

content > (audio, video, image) 

i want perform queries on parent model content.objects.filter() or content.objects.recent(). how come this? presently using django's concrete model inheritance, suppose impose lot of overheard on db performance using joins parent classes. cannot use abstract class because not permit me perform queries on parent class. here models definitions:

class basecontent(models.model): """     concrete base model encompass local , social content.     need single queryset content on app. """     title = models.charfield(_('title'), max_length=255, default='')     description = models.textfield(_('description'), default='', blank=true)     publisher = models.foreignkey(settings.auth_user_model)      allow_comments = models.booleanfield(default=false)     is_public = models.booleanfield(default=true)      created = autocreatedfield(_('created'))      objects = basecontentmanager()   class video(basecontent):     activity_action = 'posted video'      upload_to = 'video_files/%y/%m/%d'     preview_upload_to = 'video_frames/%y/%m/%d'      video_file = models.filefield(_('video file'), upload_to=upload_to)     preview_frame = models.imagefield(         _('preview image'), upload_to=preview_upload_to, blank=true,         null=true)     category = models.foreignkey(videocategory, blank=true, null=true)     num_plays = models.positiveintegerfield(blank=true, default=0)     num_downloads = models.positiveintegerfield(blank=true, default=0) 

thanks in advance.

i've had similar scenario have solved using external named django polymorphic, library seemed work seamlessly. few major projects use django polymorphic including django-shop.

link: https://github.com/chrisglass/django_polymorphic

don't quote me on i've read few sources in past have mentioned django_polymorphic models not have same performance issues caused standard django orm concrete inheritance implementation.


Comments