Add __str__ method to have a better representation in admin interface
This commit is contained in:
parent
c7da144f5e
commit
e34b95f592
|
@ -24,6 +24,9 @@ class Asset(models.Model):
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('asset:detail', kwargs={'pk': self.pk})
|
return reverse('asset:detail', kwargs={'pk': self.pk})
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.named_id + ' (' + str(self.quantity) + '): ' + self.description
|
||||||
|
|
||||||
|
|
||||||
class GtinProduct(models.Model):
|
class GtinProduct(models.Model):
|
||||||
gtin = models.CharField(max_length=40, unique=True)
|
gtin = models.CharField(max_length=40, unique=True)
|
||||||
|
@ -33,3 +36,6 @@ class GtinProduct(models.Model):
|
||||||
brand = models.CharField(max_length=40, blank=True)
|
brand = models.CharField(max_length=40, blank=True)
|
||||||
created_ts = models.DateTimeField('datetime created', auto_now_add=True)
|
created_ts = models.DateTimeField('datetime created', auto_now_add=True)
|
||||||
changed_ts = models.DateTimeField('datetime updated', auto_now=True)
|
changed_ts = models.DateTimeField('datetime updated', auto_now=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.gtin + ': ' + self.name
|
||||||
|
|
|
@ -16,3 +16,6 @@ class Scanner(models.Model):
|
||||||
changed_ts = models.DateTimeField('datetime updated', auto_now=True)
|
changed_ts = models.DateTimeField('datetime updated', auto_now=True)
|
||||||
changed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET(get_deleted_user),
|
changed_by = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.SET(get_deleted_user),
|
||||||
related_name='changed_scanners')
|
related_name='changed_scanners')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.named_id + ': ' + self.description + ' (' + str(self.last_online_ts) + ')'
|
||||||
|
|
Loading…
Reference in New Issue