Home > front end >  Django CBV: How come my child method is not overriding my parent method?
Django CBV: How come my child method is not overriding my parent method?

Time:01-10

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!

CodePudding user response:

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!

  • Related