File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed
import_export_celery/models Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -10,3 +10,4 @@ example/django-import-export-celery-export-jobs/
1010pipenv /
1111django_import_export_celery.egg-info /
1212db /
13+ .idea /
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ class WinnersResource(ModelResource):
2727 class Meta :
2828 model = Winner
2929
30+ def get_export_queryset (self ):
31+ """To customise the queryset of the model resource with annotation override"""
32+ return self .Meta .model .objects .all ()
33+
3034
3135class WinnersWithAllCapsResource (WinnersResource ):
3236 name_all_caps = Field ()
Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ def get_content_type(self):
100100
101101 def get_queryset (self ):
102102 pks = json .loads (self .queryset )
103+ # If customised queryset for the model exists
104+ # then it'll apply filter on that otherwise it'll
105+ # apply filter directly on the model.
106+ resource_class = self .get_resource_class ()
107+ if hasattr (resource_class , "get_export_queryset" ):
108+ return resource_class ().get_export_queryset ().filter (pk__in = pks )
103109 return self .get_content_type ().model_class ().objects .filter (pk__in = pks )
104110
105111 def get_resource_choices (self ):
You can’t perform that action at this time.
0 commit comments