else {
$("#modal .modal-content").html(data.html_user_form);
}
$("#user-symbol").val( ui.item.desc );
<style>
.ui-front {
z-index: 1100;
}
</style>
success: function (data) {
$("#modal .modal-content").html(data.html_user_form);
$("#user_class").autocomplete({
source: "/user_autocomplete/",
minLength: 2
});
}
<form method='post'>
{% csrf_token %}
{{ formset.management_form }}
{% for form in formset %}
<label for="{{ form.is_visible.id_for_label }}">
{{ form.is_visible }} {{ form.is_visible.label }}
</label>
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endfor %}
<input type='submit'>
</form>
<form method='post'>
{% csrf_token %}
{% for form in formset %}
<label for="{{ form.is_visible.id_for_label }}">
{{ form.is_visible }} {{ form.is_visible.label }}
</label>
{% endfor %}
<input type='submit'>
</form>
def formset_test(request):
formset = ProductFormSet(request.POST or None, queryset=Product.objects.all())
if request.method == 'POST':
print formset.is_valid()
if formset.is_valid():
formset.save()
context = {
'formset': ProductFormSet(queryset=Product.objects.all())
}
return render(request, 'template.html', context)
class ProductForm(forms.ModelForm):
class Meta:
model = Product
fields = 'is_visible',
def __init__(self, *args, **kwargs):
super(ProductForm, self).__init__(*args, **kwargs)
self.label_suffix = ''
self.fields['is_visible'].label = self.instance.name
ProductFormSet = modelformset_factory(Product, max_num=0, form=ProductForm)
{% for product_form in product_formset %}
{{ product_form.is_visible.field }}<label for="{{ product_form.is_visible.id_for_label }}">{{ product_form.name.value }}</label>
{% endfor %}
ProductFormSet = modelformset_factory(Product, fields=('is_visible',))
product_formset = ProductFormSet(request.POST, queryset=Product.objects.all())