Skip to content

Instantly share code, notes, and snippets.

@dennohpeter
Forked from mushonnip/models.py
Created February 4, 2021 11:32
Show Gist options
  • Save dennohpeter/e5236d9c0e85c5efdb16ca7e0fd03f0c to your computer and use it in GitHub Desktop.
Save dennohpeter/e5236d9c0e85c5efdb16ca7e0fd03f0c to your computer and use it in GitHub Desktop.
Django model to generate unique id/ booking id/ transaction id
import uuid
class Booking(models.Model):
booking_no = models.CharField(primary_key=True, default=uuid.uuid4().hex[:5].upper(), max_length=50, editable=False)
def __str__(self):
return str(self.booking_no)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment