Am not 100% sure about this, but what about creating a normal Integer field, then override the save method of the model to auto-increment the value starting from 1000 ? So that any new record added, its value will be 1000+ total record +1
On Aug 8, 2015 11:11 AM, "Holland_zwz" <hollandzwz@gmail.com> wrote:
-- Hi all,--I want to add one auto-increase PK which start from one given value(such as start from 1000).I try to write the model as following:class MyModel(models.Model):mid = models.AutoField(verbose_name='My ID',primary_key=True,default='1000')But only one record can be add when i add records in admin web site.Any ways to support this? thanksRegards,Hollandz
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a66c5ec3-d0e8-41c8-98df-ef2c6f6c7126%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMGzuy8-XVWS%2BiR%3DDidHC_PO8_HS_w1P%3Dpnff5Pgt-y4RVHVcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment