Fix multiput with proxy submodels#237
Conversation
fa02024 to
8db9639
Compare
8db9639 to
eb46c18
Compare
|
additional explanation of the issue: The thing is that with proxy model we have a superclass, but there is no pointer to it- because proxy model is pure python wrapper to existing model so that it can be extended with additional logic, have separate view etc. So if we try to save a model that has proxy submodel then it fails with 500 trying to get non existing remote_field |
Local testing uses a different package install process then the CI. To prevent us running postgres 12 default while local testing bu use 11 instead we must also use django 3. To enable this we in the setup.py which is used for local testing require a django 3 version instead of a django 3 or 4 version. Since django 4 is only postgres 12+ compatible. Co-authored-by: Bob Booij-Liewes <bob@codeyellow.nl>
BBooijLiewes
left a comment
There was a problem hiding this comment.
After changes all OK, lets rework setup.py testing later:
#243
This PR fixes a bug where in some scenarios, when using multiput on a models that have proxy submodel(a submodel without a db table) it would fail on trying to override superclass for that model instance(
_multi_put_override_superclassmethod in theviews.pyfile).Example stacktrace of the error:
Given the purpose of that method I think it is not needed to override the superclass with proxy subclass- it is essentialy the same model from the db perspective. Thats why when this happens I added
continuestatement in the subclass loop, so it tries to search for a valid subclass for overriding.Infact the newly added test is not really needed. Adding
Petproxy model, that inherits fromAnimalmodel is enough for existing inheritance tests to break.Additionaly after adding support for Django 4, the docker setup required bumping the version of Postgres container to 12 in order to work.