BaseModel __unicode__ method now returns str(pk) if the 'name' attribute does not exist

This commit is contained in:
Dana Van Aken 2019-08-27 13:23:18 -04:00
parent 7c964758e9
commit e6a57d4c92
1 changed files with 8 additions and 2 deletions

View File

@ -224,7 +224,7 @@ class Session(BaseModel):
class SessionKnobManager(models.Manager): class SessionKnobManager(models.Manager):
@staticmethod @staticmethod
def get_knobs_for_session(session): def get_knobs_for_session(session):
# Returns a dict of the knob # Returns a dict of the knob
knobs = KnobCatalog.objects.filter(dbms=session.dbms) knobs = KnobCatalog.objects.filter(dbms=session.dbms)
knob_dicts = list(knobs.values()) knob_dicts = list(knobs.values())
for i, _ in enumerate(knob_dicts): for i, _ in enumerate(knob_dicts):
@ -422,12 +422,18 @@ class PipelineRun(models.Model):
start_time = models.DateTimeField() start_time = models.DateTimeField()
end_time = models.DateTimeField(null=True) end_time = models.DateTimeField(null=True)
def __unicode__(self):
return str(self.pk)
def __str__(self):
return self.__unicode__()
class Meta: # pylint: disable=old-style-class,no-init class Meta: # pylint: disable=old-style-class,no-init
ordering = ["-id"] ordering = ["-id"]
class PipelineData(models.Model): class PipelineData(models.Model):
pipeline_run = models.ForeignKey(PipelineRun) pipeline_run = models.ForeignKey(PipelineRun, verbose_name='group')
task_type = models.IntegerField(choices=PipelineTaskType.choices()) task_type = models.IntegerField(choices=PipelineTaskType.choices())
workload = models.ForeignKey(Workload) workload = models.ForeignKey(Workload)
data = models.TextField() data = models.TextField()