last day (15 days later) » 

7:01 AM
0
Q: Django Get value of form field in Update View

AbedyI am using class based views and want to get the current value of a given field ward in my UpdateView's get_context_data method. I've tried using the get method but it isn't working. Here's my method: def get_context_data(self, **kwargs): context = super(ApplicationUpdateView, self).get_cont...

 
Where do you want to use this in POST or GET request?
Also share the entire view and the corresponding url.
 
@AtleyVarghese My Form uses POST method but now in my Update View I want to get the current value of that particular field.
 
on Form submit right?
 
Not on form submit. When the form is loaded. That is, when I load my UpdateView URL @AtleyVarghese
 
The get_context_data() is used to send context to template it is called during a GET request.
During a GET request self.request.POST will be empty
When a form is initially loaded it is a get request the only way to get values to get content function is from url kwargs or from database.
How do you plan to send the ward valu to the view in GET request
 
7:01 AM
I intend to use the value of that particular ward to filter some query and then throw the result back to the template @AtleyVarghese
Also note the updated changes in my question
 
How do you plan to send the ward value to the view in GET request
 
I am only using that GET request to get that value. If there's any other way to get that value (and not on form submit) I'd be so happy to use it.
Like, Is there any way I can get the current values of a form in an UpdateView?
 
7:19 AM
From where the ward value comes to the view
 
Yes. And I think I solved it. Through the self.get_object() method. thanks for the help though. :-)
 

last day (15 days later) »