'django get the value enside formvalid

I am trying to obtain the value of the val variable that is inside form_valid but I cannot obtain it.

Does anyone have any idea what I'm doing wrong?

class Cotizar(CreateView):
    template_name = "cotizar.html"
    model = Servicio
    fields = ['no_servicio', 'precio']
    #success_url = '/Cotizar/48'

    def form_valid(self, form):
        value = 90
        a = Cotizacion( numcot = "{}".format(numerocotizacion()) ,empresa_id = self.kwargs["pk"] )
        a.save()
        form.instance.cotizacion_id = cotizacion_id = a.pk
        return super().form_valid(form)

    def get_context_data(self, **kwargs):
        contexto = super().get_context_data(**kwargs)
        contexto['productserv'] = Servicio.objects.all()
        contexto['empresa'] = Empresa.objects.get(pk = self.kwargs['pk'])
        return contexto

    def get_success_url(self, **kwargs):
        #slug = Empresa.objects.get(id=self.kwargs["pk"]).slug
        return reverse_lazy('cotizando', kwargs = {'pk': self.kwargs["pk"], 'num_cot':self.value})
        # return reverse_lazy('v', kwargs={'pk': self.object["pk"]}) 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source