-
-
Save anikwai/5774b33a5d2dd75226aa30c01b03362d to your computer and use it in GitHub Desktop.
Django model to generate unique id/ booking id/ transaction id
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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