What I am trying to do is, fetching data from a third party app and show it on the page. I will get the data in get_context_data function and use the same data in get_initial method as well. I could not manage to do that. Is there any way to do that?
Example Code
class UpdateView(generic.FormView):
template_name = 'test.html'
form_class = myForm
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
MYVARIABLE = fetch_data_from_3rd_party_app()
context["MYVARIABLE"] = MYVARIABLE
return context
def get_initial(self):
initial = super().get_initial()
# I want to assign MYVARIABLE.data to initial["data"] here.
initial["data"] = MYVARIABLE
return initial