milkman icon indicating copy to clipboard operation
milkman copied to clipboard

Update milkman/dairy.py

Open AdrienLemaire opened this issue 12 years ago • 1 comments

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 !

AdrienLemaire avatar Dec 23 '11 17:12 AdrienLemaire

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.

paltman avatar Jul 17 '12 03:07 paltman