Below is the Model.py
from django.db import models
class workflow_details(models.Model):
workflow_name = models.CharField(max_length=20,)
workflow_id = models.IntegerField(primary_key=True)
workflow_status=models.BooleanField()
def __str__(self):
return self.workflow_id
class Meta:
app_label = 'workflows'
verbose_name_plural = 'Workflow Details'
class workflow_steps(models.Model):
workflow_id=models.ForeignKey('workflows.workflow_details',to_field='workflow_id',on_delete=models.CASCADE)
step_id=models.CharField(max_length=20,primary_key=True)
step_name=models.CharField(max_length=20)
is_start=models.BooleanField()
is_end=models.BooleanField()
previous_step_id=models.CharField(max_length=20)
next_step_id=models.CharField(max_length=20)
step_function=models.CharField(max_length=255)
def __str__(self):
return self.step_id
class Meta:
app_label = 'workflows'
verbose_name_plural = 'Workflow Steps'
class workflow_execution(models.Model):
workflow_id=models.ForeignKey('workflows.workflow_details',to_field='workflow_id',on_delete=models.PROTECT)
execution_id=models.CharField(max_length=30,primary_key=True)
step_id=models.CharField(max_length=20)
step_name=models.CharField(max_length=20)
is_start=models.CharField(max_length=5)
is_end=models.CharField(max_length=5)
previous_step_id=models.CharField(max_length=20,default='')
next_step_id=models.CharField(max_length=20,default='')
start_time=models.CharField(max_length=20,default='')
end_time=models.CharField(max_length=20,default='')
execution_time=models.CharField(max_length=20,default='')
success=models.CharField(max_length=5,default='')
failure=models.CharField(max_length=5,default='')
current_status=models.CharField(max_length=10,default='')
def __str__(self):
return str(self.execution_id)
class Meta:
app_label = 'workflows'
verbose_name_plural = 'Workflow Execution'
below is the snippet of the code i am using to insert data in it
def register_run(self,workflow_id,execution_id):
wd = workflow_details.objects.filter(workflow_id=workflow_id)
ws = workflow_steps.objects.filter(workflow_id=workflow_id).values()
sorted_data = sorted(ws, key=lambda x: x['step_id'])
for data in sorted_data:
step_id=data.get('step_id')
step_name=data.get('step_name')
is_start=data.get('is_start')
is_end=data.get('is_end')
previous_step_id=data.get('previous_step_id')
next_step_id=data.get('next_step_id')
we=workflow_execution(workflow_id=wd,execution_id=execution_id,step_id=step_id,step_name=step_name,is_start=is_start,is_end=is_end,previous_step_id=previous_step_id,next_step_id=next_step_id,current_status='idle')
we.save()
return True
I am constantly getting the below error
__str__ returned non-string (type int)
Even though the return type for the class is set as string
Below is the image for reference
Please help me point out the exact issue