I am trying to modify my get_success_url so that if any kwargs passed to it, I can create a return url using them.
Here is what I still have:
class CalcUpdate(SuccessMessageMixin, UpdateView): model = Calc template_name = 'calc/cru_template.html' form_class = CalcForm def archive_calc(self, object_id): model_a = Calc.objects.get(id = object_id) model_b = Calc() for field in model_a._meta.fields: setattr(model_b, field.name, getattr(model_a, field.name)) model_b.pk = None model_b.save() self.get_success_url(idnumber = model_b.pk) def form_valid(self, form):
For now, it just gives keyerror detailed description of 'idnumber' .
I typed kwargs['idnumber'] and it returns pk as expected, but I just can't see where I'm wrong.
Thanks in advance.
source share