from django import forms from django.forms.utils import ValidationError from .models import LuxOptionContact class LuxOptionsForm(forms.ModelForm): contracts = forms.IntegerField() class Meta: model = LuxOptionContact fields = [ 'symbol', 'strike_price', 'expiration_date', 'contract_open_price', 'call_put', 'contracts' ] def save(self, commit=True): i = 0 while i < int(self.cleaned_data['contracts']): print(i, "contracts") i = i+1 return super(LuxOptionsForm, self).save(commit=commit)