问题
I'm getting this error after submitting my form(it uses inlines and foreign keys).
This is a follow up to my question: How to save a model in ModelForm with two ForeignKey fields in Django
Now my views.py looks like this:
def CreateFlo(request):
EstadosInlineFormSet = inlineformset_factory(Listaflor, Flora2Estado, form=Flo2Form)
floForm = FloForm(request.POST)
if request.method == 'POST':
if floForm.is_valid():
new_flo = floForm.save()
estadosInlineFormSet = EstadosInlineFormSet(request.POST, request.FILES, instance=new_flo)
if estadosInlineFormSet.is_valid():
estadosInlineFormSet.save()
else:
estadosInlineFormSet = EstadosInlineFormSet()
floForm = FloForm()
context = {'floForm': floForm}
return render(request, 'accounts/enviar_flora.html', context)
enviar_flora.html:
<div class="form_page">
<h3>{{texto}}</h3>
<h2>Enviar Espécie</h2>
<form action="" method="POST">
{% csrf_token %}
{{ floForm.as_table }}
{{ floForm.management_form }}
<input type="submit" name="Enviar" value="Enviar" id="enviar">
</form>
</div>
full error: https://i.stack.imgur.com/rIaUz.png
来源:https://stackoverflow.com/questions/66013168/django-managementform-data-is-missing-or-has-been-tampered-with-foreign-manyto