django-fixture-magic icon indicating copy to clipboard operation
django-fixture-magic copied to clipboard

query using the call_command

Open ssharma80 opened this issue 5 years ago • 1 comments

Could you advise how to use the dump_object command with query programatically using the call_command ?

Consider this from django.core.management import call_command q = UploadedFile.objects.filter(user=user).values('pk') call_command('dump_object', 'validate.UploadedFile', '--no-follow', query=''{"pk__in": ' + str(list(q)) + '}'')

Do sent seem to work ? Any solutions ?

ssharma80 avatar Mar 19 '19 13:03 ssharma80

For everyone stumbling upon the same problem: I got this to work as follow:

from django.core.management import call_command

ids = tuple(UploadedFile.objects.filter(user=user).values_list('pk', flat=True))

call_command('dump_object', 'validate.UploadedFile', *ids, '--no-follow'')

ghost avatar Sep 14 '20 09:09 ghost