Just like how Django models automatically create an integer ID for each column entry of a database table, I would like it to automaticallty create an alpha numeric ID as well.
The integer can increment, while the character should be cycle through A-Z.
1_A
2_B
3_C
.
.
.
27_A
28_B
And so on.
Here is my models.py
from django.db import models
class Sample(models.Model):
sample_ID = models.CharField(max_length=20) # Alpha numeric ID described above.
sample_name = models.CharField(max_length=30)
As you can tell, this will produce a blank text field for users to enter this value in, though I would like it to be auto generated just as with the integer id. This will then be a fixed ID.
What confuses me about this is that I don't know how to incorporate customized/automated fields into a model (I am quite new to Django). Is there already a field that can do this? Or how can I make a custom field?
Django = 1.8
python = 2.7
Thank you