/为以10为底的int()添加无效的文字时出现ValueError:“ O”

时间:2018-10-03 05:17:08

标签: python django

“多对多”字段“位置”保存到数据库中,但网页返回此错误。

  

“ / Add处的ValueError

     

int()以10为底的无效文字:'O'“

models.py

INSIDEOUTSIDE = (
    ('In','Inside'),
    ('Out', 'Outside'),
)

class location1(models.Model):
    locate = models.CharField(max_length=3, choices=INSIDEOUTSIDE)
    def __str__(self):
        return self.locate

class Reservation(models.Model):
    name = models.CharField(max_length=22)
    psize = models.IntegerField('Party Size')
    Date = models.DateField()
    Time = models.Tienter code heremeField()
    location = models.ManyToManyField(location1, choices= INSIDEOUTSIDE)

forms.py

class ReservationsForm(forms.ModelForm):
    class Meta:
        model = Reservation
        fields = ('name', 'psize', 'Date', 'Time', 'location')
        widgets = {'Date': SelectDateWidget(),}

views.py

def add(request):
    form = ReservationsForm(request.POST, request.FILES)
    if request.method == "POST":
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('Add')
    else:
        form = ReservationsForm()
    return render(request,'app/Add.html',{'form': form})

0 个答案:

没有答案