I created a class that inherits from DetailView, and I overrided the methods get_context_data and post. What it seems weird as mentioned in the title, is that I can call self.object from get_context_data but I can't from post so I had to use self.get_object() instead. But I would like to understand why? is self.object removed by get_context_data? so that any method called after it cannot use it or something like that?
Thanks in advance
post method doesn't exist by default in DetailView, you actually creating it not overriding, so therefore you need to fetch the object by yourself, the reason it'a available in get_context_data is that it's already fetched inside get method and saved in object property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With