diff --git a/oshipka/webapp/views.py b/oshipka/webapp/views.py index f2e1ae0..6a8f9ef 100644 --- a/oshipka/webapp/views.py +++ b/oshipka/webapp/views.py @@ -30,7 +30,7 @@ def get_view(model_view, template, template_ctx_func=None): def serialize_form(): - return dict(request.form) + return dict(filter(lambda k: not k[0].startswith("__"), dict(request.form).items())) def update_view(model_view, template): @@ -55,10 +55,11 @@ def update_view(model_view, template): return inner -def create_view(model_view, template, post_add=None, post_create=None): +def create_view(model_view, template, template_ctx_func=None, post_add=None, post_create=None): def inner(): if request.method == "GET": - return render_template(template) + template_ctx = template_ctx_func() if template_ctx_func else {} + return render_template(template, **template_ctx) serialized_form = serialize_form() _next = serialized_form.pop('_next') if '_next' in serialized_form else None