You need not to do anything with choice field in forms.py you can directly use it in your template.
template
<form action="" method="post">
{% csrf_token %}
<label for="order_no">Order No.:</label>
<input type="text" class='form-control' value="{{Order}}" name="order_no" readonly><br>
<label for="isbn">ISBN No.:</label>
<input type="text" class='form-control' value="{{ISBN}}" name="isbn" readonly><br>
<label for="rate">Rate:</label>{{forms.rate}}(Rate us 10 is the Highest and 1 is the lowest)<br><br>
<label for="comment">Comments</label>{{forms.comment}}<br><br>
<input type="submit" class="btn btn-success">
</form>
Models.py
RATING=( (1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (10,10) )
class returnbook(models.Model):
order_no=models.IntegerField(blank=True,null=True)
isbn=models.CharField(max_length=15)
rate=models.IntegerField(choices=RATING,default='1')
comment=models.TextField(max_length=20000,blank=True)
user=models.CharField(max_length=50)
class Meta:
unique_together = ('order_no', 'isbn')
def __unicode__(self):
return unicode(self.rate)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…