Django is a form builder. How to update the form?

I use django-forms-builderin my project, and there is only one thing that I can not say. How to configure the update form to edit the completed form?

Here is my attempt to make an update form for django-forms-builder

urls.py

url('forms/update/(?P<pk>\d+)/$', FormUpdateView.as_view(),
                                 name='form-update'),

views.py

class FormUpdateView(UpdateView):
    model = FieldEntry
    template_name = 'form/update_form.html'
    form_class = FormForForm
    success_url = '/assessments/all/'

update-form.py

{% render_built_form id=form_instance.id %}
+4
source share
1 answer

, , . CBV, . , , ( CBV) . (if request.METHOD == "POST":#update the row). , - HTML-, form_builder . , FormEntry, . .

views.py

from forms_builder.forms.models import Form

def get_form(request, slug, pk):
    form_obj = Form.objects.get(slug=slug)
    form_instance = form_obj.entries.get(pk=pk)
    form = FormForForm(form=form_obj, instance=form_instance, context=request)
    return render_to_response('update_form.html', {'form':form_instance.form, 'request':request})

/update_form.html

{{ form.as_p }}
+4

All Articles