Skip to content

Instantly share code, notes, and snippets.

@anikwai
Forked from mushonnip/models.py
Created November 8, 2022 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anikwai/5774b33a5d2dd75226aa30c01b03362d to your computer and use it in GitHub Desktop.
Save anikwai/5774b33a5d2dd75226aa30c01b03362d 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