mi problema es el siguiente: tengo un form que guarda los datos de una presentacion artistica(modelo_M2) y a esa presentacion artistica tengo que asociarle la distribucion de los pagos a los diferentes artistas que participaron necesito crear multiples formularios de pago en un mismo templete en base a la cantidad de artistas que tenga la unidad artistica osea un modelo de pago por cada artista de la unidad artistica
from django import forms
from .models import Modelo_M2, Pago
from common.models import Unidad_Artistica, Cliente, Zona_Pago, Comercial
class modelo_M2_form(forms.ModelForm):
id_m1 = forms.CharField(max_length=10, widget=forms.TextInput(attrs={'class': 'form-control'}))
id_m2 = forms.CharField(max_length=10, widget=forms.TextInput(attrs={'class': 'form-control'}))
unidad_artistica = forms.ModelChoiceField(queryset=Unidad_Artistica.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
comercial = forms.ModelChoiceField(queryset=Comercial.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
realizado = forms.DateField(widget=forms.DateInput(attrs={'class': 'form-control'}))
captado = forms.DateField(widget=forms.DateInput(attrs={'class': 'form-control'}))
cliente = forms.ModelChoiceField(queryset=Cliente.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
presentaciones = forms.DecimalField(max_digits=2, widget=forms.NumberInput(attrs={'class': 'form-control'}))
zona_pago = forms.ModelChoiceField(queryset=Zona_Pago.objects.all(), widget=forms.Select(attrs={'class': 'form-control'}))
total = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
empresario = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control', 'value': '0'}))
gastos = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control', 'value': '0'}))
centro = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
total_unidad_artistica = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
class Meta:
model = Modelo_M2
fields = '__all__'
class Pago_form(forms.ModelForm):
ci = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
nombre_apellido = forms.CharField(max_length=255, widget=forms.TextInput(attrs={'class': 'form-control'}))
importe = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
porciento_onat = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
descuento_onat = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control', 'value': '5', 'disable': 'true'}))
ganado = forms.FloatField(widget=forms.NumberInput(attrs={'class': 'form-control'}))
class Meta:
model = Pago
fields = '__all__'