Making auto field Django in certain format in model.py

I'm trying to make auto field like that for invoice which is either part of customers table or invoice table it is okay in the 2 sitautions

the format I want like this Year-Month-auto depends on the number before it for example : 202201-001 the first one , 202205-504 like that and it's auto generted once I create new customer

model.py

class enquiry(models.Model):
    enq_id = models.AutoField(auto_created = True, primary_key=True)
    name = models.CharField(max_length=100)
    Parent_name = models.CharField(max_length=100)
    Phone1 = models.IntegerField(unique=True)
    Phone2 = models.IntegerField()
    email = models.EmailField()
    place = models.CharField(max_length=50)
    DOB = models.DateField()
    # age = models.IntegerField(null=True)
    def __str__(self):
        return self.name 

I'm trying to make full auto id for my invoices so I can use in my view

Back to Top