Django CBV: How come my child method is not overriding my parent method?

Question:

I’m pretty new when it comes to python classes / django CBVs. I’m trying to have a method (print_test) from my child class override my parent class, but I can’t get it to work. What am I doing wrong?

Below is my parent:

parent

This is my child:

child

I’ve tried a bunch of things but can’t see to get it to work :/

Appreciate all help!

Asked By: Matt S

||

Answers:

I realized my folly…

The print_test() in the parent is tucked under the Post() method, but the print_test() method in the child class is not. So the scopes don’t match up and thus it doesn’t get overwritten.

When I moved the print_test() method in the parent class outside of the post(), it was overwritten!

Answered By: Matt S