What I needed: A document number with a fixed number of integers that would also act like an AutoField
.
My searches took me all over incl. this page.
Finally I did something like this:
I created a table with a DocuNumber
field as an IntegerField with foll. attributes:
max_length=6
primary_key=True
unique=True
default=100000
The max_length
value anything as required (and thus the corresponding default=
value).
A warning is issued while creating the said model, which I could ignore.
Afterwards, created a document (dummy) whence as expected, the document had an integer field value of 100000.
Afterwards changed the model key field as:
AutoField
max_length
And default
attributesprimary_key = True
attributeThe next (desired document) created had the value as 100001 with subsequent numbers getting incremented by 1.
So far so good.