In django admin page, One mobile has 10 indexes associated with it as listed in lst. Index should be readonly field. index field should auto increment each time if I repeat mobile number in forms. For new mobile number index should start from 1. form wont accept new entry if I repeat mobile eleventh time. Please help me on this. I am very new to django. Thanks in advance.
from django.db import models
from django.core.validators import MaxLengthValidator
from django.db import models
class Customer(models.Model):
lst = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five'), (6,'six'), (7, 'seven'), (8, 'eight'),
(9, 'nine'), (10, 'ten')]
name = models.CharField(max_length=50, default='ABC')
address = models.CharField(max_length=80, default='ABC')
id = models.PositiveIntegerField(default='0000', primary_key=True)
mobile = models.IntegerField(default='0')
index = models.PositiveIntegerField(choices=lst, default=lst[0])
def __str__(self): # __unicode__ on Python 2
return "%s" % self.name