Skip to content
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

Custom dump nested deps #39

Open
dwatkinsweb opened this issue Feb 25, 2016 · 3 comments · Fixed by solarmonkey/django-fixture-magic#2
Open

Custom dump nested deps #39

dwatkinsweb opened this issue Feb 25, 2016 · 3 comments · Fixed by solarmonkey/django-fixture-magic#2

Comments

@dwatkinsweb
Copy link

Currently if you have multiple levels of dependencies, custom_dump command only goes one level deep through straight foreign keys and not reverse foreign keys. It goes from the parent to get the children, but will only get grandchild if it can access it directly from the parent.

It would be nice to be able to use something like

CUSTOM_DUMPS = {
    'addon': {  # Initiate dump with: ./manage.py custom_dump addon id
        'primary': 'addons.addon',  # This is our reference model.
        'dependents': [  # These are the attributes/methods of the model that we wish to dump.
            'current_version',
            'current_version.files.all.0',
            {
                'primary': 'previous_versions.all',
                'dependents': ['files.all']
            }
        ],
        'order': ('app1.model1', 'app2.model2',),
        'order_cond': {'app1.model1': lambda x: 1 if x.get('fields').get('parent_model1') else 0,
                        'app2.model2': lambda x: -1 * x.get('pk')},
    }
}
dwatkinsweb pushed a commit to dwatkinsweb/django-fixture-magic that referenced this issue Feb 25, 2016
dwatkinsweb pushed a commit to dwatkinsweb/django-fixture-magic that referenced this issue Feb 25, 2016
@davedash
Copy link
Owner

@dwatkinsweb this seems interesting - looks like you are taking a stab at this, when you do submit a PR mind adding some tests for this case?

@dwatkinsweb
Copy link
Author

@davedash I can add some unit tests for this and hopefully have a pull request in the next couple days. I have limited time to work on it in the evening. I just hacked something quickly together that works for my specific use case but shouldn't require much more to it to be more universal and I can try to add a few unit tests to it as well.

@davedash
Copy link
Owner

No worries, and take your time. I understand time limits and OSS. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants