我想输入数据库。但当identity\u insert设置为off时,这是“索赔案例”(544).我在数据库中设置了identity\u insert,并且我没有使用from插入主键。其他领域看起来不错。我试过不同的组合。
如果我设置参数form.save(commit=false)form pass-through。我正在学习django,我只是不知道现在该找什么。这个错误是否与polybase服务有关?
型号.py
class Factclaimcases(models.Model):
idfactclaimcase = models.IntegerField(db_column='IdFactClaimCase', primary_key=True) # Field name made lowercase.
idtechnican = models.ForeignKey(Dimtechnican, models.DO_NOTHING, db_column='IdTechnican') # Field name made lowercase.
thedate = models.ForeignKey(Dimdate, models.DO_NOTHING, db_column='TheDate') # Field name made lowercase.
description = models.CharField(db_column='Description', max_length=50) # Field name made lowercase.
manufacturedef = models.BooleanField(db_column='ManufactureDef', blank=True, null=True, default=False) # Field name made lowercase. This field type is a guess.
doc = models.BinaryField(db_column='Doc', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'FactClaimCases'
def __str__(self):
return self.name
表单.py
class Factclaimcases_input(forms.ModelForm):
class Meta:
model = Factclaimcases
fields = ("idtechnican", 'thedate', 'description')
视图.py
def send(request):
pks=request.POST.getlist('check')
selected_objects = Factclaim.objects.filter(pk__in=pks)
table = tab_recent_claims(selected_objects)
form = Factclaimcases_input(request.POST)
if request.method == "POST":
if form.is_valid():
form.save()
return redirect('claim_cases')
print(form)
else:
form = Factclaimcases_input()
return render(request, 'test.html', {'table': table, 'pks': pks, 'form': form})
暂无答案!
目前还没有任何答案,快来回答吧!