Здравствуйте, я пытаюсь создать рабочий процесс esignature, используя viewflow. Я делаю это, связывая мою модель процесса, с моделью esignature, где я храню подписи с помощью внешнего ключа. Тем не менее, я сталкиваюсь с этой ошибкой.
Cannot assign "8": "ESignatureModel.paymentVoucherProcess" must be a "PaymentVoucherProcess" instance.
Мои flows.py
class Pipeline(Flow):
process_class = PaymentVoucherProcess
start = (
flow.Start(
CreateProcessView,
fields=["payment_code","bPBankAccount"]
).Permission(
auto_create=True
).Next(this.approve)
)
approve = (
flow.View(
Signature,
fields=["eSignatureModel"]
).Permission(
auto_create=True
).Next(this.check_approve)
)
check_approve = (
flow.If(lambda activation: activation.process.eSignatureModel)
.Then(this.send)
.Else(this.end)
)
send = (
flow.Handler(
this.send_hello_world_request
).Next(this.end)
)
end = flow.End()
def send_hello_world_request(self, activation):
print(activation.process.payment_code)
Вот мой models.py
class PaymentVoucherProcess(Process):
payment_code = models.CharField(max_length=250,default='sup')
bPBankAccount = models.ForeignKey('BPBankAccount', on_delete=models.CASCADE)
drop_status = models.CharField(
null=True, max_length=3, default=None,
choices=(('SCF', 'Successful'),
('ERR', 'Unsuccessful'))
)
remarks = models.TextField(null=True)
class ESignatureModel(JSignatureFieldsMixin):
name = models.ForeignKey(User , on_delete=models.CASCADE)
paymentVoucherProcess = models.ForeignKey('PaymentVoucherProcess', on_delete=models.CASCADE)
Вот мой внешний пользовательский вид Я использовал для вставки аспекта подписи в мой рабочий процесс
@flow_view
def Signature(request):
form = SignatureForm(request.POST or None)
if form.is_valid():
esig = ESignatureModel()
signature = form.cleaned_data.get('signature')
if signature:
signature_picture = draw_signature(signature)
signature_file_path = draw_signature(signature, as_file=True)
pk = request.activation.process.pk
#attempting to assign the foreign key field error occurs here
esig.paymentVoucherProcess = pk
form.save()
request.activation.done()
return redirect(get_next_task_url(request, request.activation.process))
return render(request, 'cash/pipeline/jsig.html', {
'form': form,
'activation': request.activation
})
Дайте мне знать, если вы заметите какие-либо мои ошибки