Tuesday, November 17, 2020

self.request.POST in get_context_data

Hi. 

I can find dozens of examples of people using "if self.request.POST:" inside of get_context_data, but as far as I can tell there is no POST in get_context_data. 

I came across this in an answer in Stack Overflow: 

>> get_context_data() is only run for GET requests (assuming you are using a FormView), and not for POST requests handled by post()
( https://stackoverflow.com/questions/38319384/passing-data-from-post-to-get-context-data )

So I experimented and as far as I can tell you don't even need POST data to populate inline formsets.  So why are so many people under the impression that you can do anything with self.request.POST inside of get_context_data and why do so many people seem to think you have to use POST data to populate inline formsets?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1bc0952b-e3ee-4eb4-b038-10b515908eden%40googlegroups.com.

No comments:

Post a Comment