def create_form(form_objects, name, request_data, id, args={}):
    if not name in form_objects:
        raise Http404()
    if id:
        instance = form_objects[name].Meta.model.objects.get(pk=id)
        form = form_objects[name](request_data or None, instance=instance)
    else:
        instance = form_objects[name].Meta.model(**args)
        form = form_objects[name](request_data or None, instance=instance)
    return form
Helper function for creating form object
dataset/ETHPy150Open gunnery/gunnery/gunnery/core/forms.py/create_form