class MyIntegerField models IntegerField def db_type self return model

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class MyIntegerField(models.IntegerField):
def db_type(self):
return models.IntegerField.db_type(self)
def get_choices(self):
ret = []
for x in Sections.objects.count():
ret.append((x,x))
return ret
class Sections(models.Model):
name = models.CharField(max_length=30)
display_name = models.CharField(max_length=30)
path = models.CharField(max_length=50)
position = MyIntegerField()