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

Update milkman/dairy.py #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AdrienLemaire
Copy link
Contributor

When using the django-polymorphic app via django-shop, I end up with my product, let's say a Video, that inherits from Product.

When I try to milkman.deliver(Video), I get the error: "can't set attribute" (would be nice to get more info about that attribute that couldn't be set btw).
Trying with milkman.deliver(Video, product=product_previously_delivered) or with milkman.deliver(Video, product_ptr=product) doesn't help.

That is explained because :

  • the field doesn't exists when it's trying to set the value in explicit_values, therefore setattr fails.
  • the field already exists in read-only for set_local_fields, so setattr fails as well.

That's why I came with those solution:

  • for set_local_fields, insure that the field doesn't already exist
  • for the explicit value, if setattr fail, hardcode the field with target.k

If you have any issues with those solutions, thanks for explaining the reasons and offering a better solution to solve that problem, thanks in advance !

@paltman
Copy link
Collaborator

paltman commented Jul 17, 2012

Thank you for this patch, however, tests currently fail with this patch. Am reviewing now to see if there is something obvious that I can do to fix.

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

Successfully merging this pull request may close these issues.

2 participants