Skip to content

Commit

Permalink
Allow selecting all pks
Browse files Browse the repository at this point in the history
  • Loading branch information
achembarpu committed Aug 3, 2018
1 parent c32e880 commit 8540a3e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fixture_magic/management/commands/custom_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Command(BaseCommand):

def add_arguments(self, parser):
parser.add_argument('dump_name')
parser.add_argument('pk', nargs='+')
parser.add_argument('pk', nargs='*')
parser.add_argument('--natural', default=False, action='store_true', dest='natural',
help='Use natural keys if they are available.')

Expand All @@ -40,8 +40,11 @@ def handle(self, *args, **options):
dump_settings = settings.CUSTOM_DUMPS[dump_name]
(app_label, model_name) = dump_settings['primary'].split('.')
include_primary = dump_settings.get("include_primary", False)
dump_me = loading.get_model(app_label, model_name)
objs = dump_me.objects.filter(pk__in=[int(i) for i in pks])
dump_me = loading.get_model(app_label, model_name).objects
if pks:
objs = dump_me.filter(pk__in=pks)
else:
objs = dump_me
for obj in objs.all():
# get the dependent objects and add to serialize list
for dep in dump_settings['dependents']:
Expand Down

0 comments on commit 8540a3e

Please sign in to comment.