def edit_chart(request, chart_id=None, chart=None): if request.method == 'POST': form = AddChartForm(request.POST, instance=chart) if form.is_valid(): chart = form.save() success=True else: success=False return {'success': success}
def charts(request, template_name='charts.html'): if request.method == 'POST': chart = Chart(user=request.user) form = AddChartForm(request.POST, instance=chart) if form.is_valid(): chart = form.save() messages.info(request, "Chart saved") else: messages.info(request, "Invalid chart: %s" % form.errors) return render_to_response(template_name, {}, RequestContext(request))