I believe its the "extra" parameter.
By default, the size is the number of objects you pass it. You can set that value to 0 by doing YourObject.objects.none()
On Wednesday, December 28, 2016 at 7:17:31 AM UTC-5, Duane Gregory wrote:
-- By default, the size is the number of objects you pass it. You can set that value to 0 by doing YourObject.objects.none()
On Wednesday, December 28, 2016 at 7:17:31 AM UTC-5, Duane Gregory wrote:
My model formset is producing an initial 7 forms, as seen here:<input id="id_form-TOTAL_FORMS" name="form-TOTAL_FORMS" type="hidden" value="7" /><input id="id_form-INITIAL_FORMS" name="form-INITIAL_FORMS" type="hidden" value="7" />I would like to alter that number, but cannot see how.view and form for ref:def micro_log_create(request):MicroLogFormSet = modelformset_factory(Micro_Log, form=MicroLogForm, max_num=4, extra=0) if request.method == 'POST':formset = MicroLogFormSet(request.POST, request.FILES)if formset.is_valid():formset.save()return reverse('micro-log')else:formset = MicroLogFormSet()return render(request, 'app/micro_log/micro_log_create.html', {'formset': formset}) class MicroLogForm(forms.ModelForm):class Meta:model = Micro_Logexclude = ['user', 'date_time']MicroLogFormSet = modelformset_factory(Micro_Log, form=MicroLogForm, max_num=4, extra=0) formset = MicroLogFormSet()Thank you
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8e444739-f6d4-4814-a678-dcc27663a00d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment