Skip to content

Fix usage of non-int ids in custom_dump #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions fixture_magic/management/commands/custom_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,20 @@ def handle(self, *args, **options):
(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])
for obj in objs.all():
try:
parsers = int, long, str
except NameError:
parsers = int, str
for parser in parsers:
try:
objs = dump_me.objects.filter(pk__in=map(parser, pks)).all()
except ValueError:
pass
else:
break
else:
objs = []
for obj in objs:
# get the dependent objects and add to serialize list
for dep in dump_settings['dependents']:
try:
Expand Down