def newRestriction(request): formRestrict = RestrictionForm(request.POST or None) if formRestrict.is_valid(): formRestrict.save() error(request, 'Информация об ограничениях успешно добавлена.') return redirect('restriction-index') var = {'formRestrict': formRestrict} return render_to_response('restaurant/restriction/edit.html', var, context_instance=RequestContext(request))
def editRestriction(request, id): restriction = Restriction.objects.get(id=id) formRestrict = RestrictionForm(request.POST or None, instance=restriction) if formRestrict.is_valid(): formRestrict.save() error(request, 'Информация об ограничении успешно изменена.') return redirect('restriction-index') var = {'restriction': restriction, 'formRestrict': formRestrict} return render_to_response('restaurant/restriction/edit.html', var, context_instance=RequestContext(request))