magnet-cl / django-project-template

A project template for Django in python 3
MIT License
14 stars 8 forks source link

refactor: Make BaseSubModelCreateView more flexible #118

Closed nstuardod closed 2 years ago

nstuardod commented 2 years ago

Allow to specify the field name that should be used to relate to parent models, along with the name that should be passed to context containing the parent object. Also, implement some magic to locate the correct FK field when no field is declared, using _meta API. To avoid overriding get and post methods, pre_get and pre_post are provided instead, with both methods being called just before the execution is transferred to the framework implementation of CBVs. In that stage, both the new and the parent objects are available.