Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ticket(models.Model):
- user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
- designation = models.CharField(max_length=255, blank=True, null=True)
- def Index(request):
- ticket = Ticket.objects.all()
- for t in ticket:
- id = len(str(t.id))
- if id == 1:
- t.designation = "#" + str("0000") + str(t.id)
- elif id == 2:
- t.designation = "#" + str("000") + str(t.id)
- elif id == 3:
- t.designation = "#" + str("00") + str(t.id)
- elif id == 4:
- t.designation = "#" + str("0") + str(t.id)
- else:
- t.designation = "#" + str(t.id)
- context = {'ticket':ticket}
- return render(request, 'ticketsystem/index.html', context)
- class Ticket(models.Model):
- user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
- ticketkennung = models.CharField(max_length=255, blank=True, null=True)
- def save(self):
- id = len(str(id))
- if id == 1:
- designation = "#" + str("0000") + str(id)
- elif id == 2:
- designation = "#" + str("000") + str(id)
- elif id == 3:
- designation = "#" + str("00") + str(id)
- elif id == 4:
- designation = "#" + str("0") + str(id)
- else:
- designation = "#" + str(id)
- super().save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement