Answer the question
In order to leave comments, you need to log in
How to get rid of the error that occurs when saving the formset?
Error occurs when saving formsets ValidationError [u"'' value must be an integer."]
Below code:
models.py
class RoyaltiesAd(models.Model):
isbn = models.CharField(max_length=45, blank=True, null=True)
supplier_num = models.CharField(max_length=45, blank=True, null=True)
advance_num = models.IntegerField(blank=True, null=True)
home_currency_amount = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
currency_amount = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
pay_question = models.IntegerField(blank=True, null=True)
invoice_rec_date = models.DateField(blank=True, null=True)
advance_note = models.CharField(max_length=255, blank=True, null=True)
class RoyaltiesAdForm(forms.ModelForm):
class Meta:
model = RoyaltiesAd
fields = '__all__'
if request.method == 'POST':
formset = RoyaltiesAdSet(request.POST)
if formset.is_valid():
formset.save()
else:
formset = RoyaltiesAdSet()
return render(request, 'template.html', {'formset': formset,})
<form method="POST" action="" enctype="multipart/form-data">
{% csrf_token %}
{{ formset }}
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question