Skip to content

Conversation

@dannyshaw
Copy link
Contributor

This PR introduces the ability to validate a child type against the parent prior to the child being saved in the database.

With restricted child_types set, django admin would not allow you to add a valid child type because it tries to validate the object before creating it in the db and the polymorphic_ctype_id is not set to be able to answer the question.

This change simply calls the available pre_save_polymorphic() method to set the id in memory prior to the check.

Test added to expose issue.

@codecov
Copy link

codecov bot commented Nov 24, 2017

Codecov Report

Merging #63 into master will increase coverage by 1%.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #63 +/- ## ======================================= + Coverage 63.84% 64.85% +1%  ======================================= Files 12 12 Lines 780 791 +11 ======================================= + Hits 498 513 +15  + Misses 282 278 -4
Impacted Files Coverage Δ
polymorphic_tree/tests/test_models.py 100% <100%> (ø) ⬆️
polymorphic_tree/models.py 63.79% <100%> (+3.79%) ⬆️
polymorphic_tree/tests/models.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6aaff56...b06fa21. Read the comment docs.

@vdboor vdboor merged commit caaa2f4 into django-polymorphic:master Dec 4, 2017
@vdboor
Copy link
Member

vdboor commented Dec 4, 2017

That is a great improvement, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants