django-fixture-magic
django-fixture-magic copied to clipboard
query using the call_command
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 ?
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'')