as the title says: how can I (in DJANGO) get data from a form in a view (in the code below is the ALIMENTA2 view) and then use that as context in another class-based view (GMO, which is a PDF report built with easy_pdf)?
I'm a noob at django, but I've tried redirect and render... I don't seem to understand exactly what I'm doing, really hahaha
views.py
def alimenta2(request):
if request.method == 'POST':
form = AlimentaForm(request.POST)
if form.is_valid():
day = form.cleaned_data['sign_date']
shipper = form.cleaned_data['shipper']
context = {'day': day, 'shipper': shipper}
#HERE IS THE PROBLEM, I WANT TO PASS THE CONTEXT:
return redirect('GMO', context=context)
else: form = AlimentaForm()
return render(request, 'agroex/alimenta2.html', {'form':form})
class GMO(PDFTemplateView):
template_name = 'agroex/gmo.html'
def get_context_data(self, **kwargs):
context = super(GMO, self).get_context_data(
pagesize='A4',
title='NON-GMO Certificate',
day=self.day,
**kwargs
)
urls.py
urlpatterns = [
path('', views.agroex, name='agroex'),
path('alimenta2/', views.alimenta2, name='alimenta2'),
path('alimenta2/GMO/', views.GMO.as_view(), name='GMO'),
]