This PR is purely for the convenience of extending PostForm and TopicForm. In my application, I create separate Post and Topic models for user comment so that they are saved in separate databases. I derive my own
class CommentPostForm(PostForm)
but I have to
Copy the implementation of PostForm.save() and TopicForm.save() to replace Post() and Topic() with my own classes, and
Call super(PostForm, self).save() instead of super().save()becausePostFormwill create aPost` object.
By factoring out create_post, update_post, create_topic, and update_topic from the save() functions, I can just override the corresponding functions.
Note that for CommentTopic to make use of Topic.save() while deriving from CommentPost, I will need to do
class CommentPost(Post):
...
class CommentTopic(Topic, CommentPost)
...
This PR is purely for the convenience of extending
PostForm
andTopicForm
. In my application, I create separatePost
andTopic
models for usercomment
so that they are saved in separate databases. I derive my ownbut I have to
PostForm.save()
andTopicForm.save()
to replacePost()
andTopic()
with my own classes, andsuper(PostForm, self).save()
instead of super().save()because
PostFormwill create a
Post` object.By factoring out
create_post
,update_post
,create_topic
, andupdate_topic
from thesave()
functions, I can just override the corresponding functions.Note that for
CommentTopic
to make use ofTopic.save()
while deriving fromCommentPost
, I will need to do