def newContact(request): formCont = ContactForm(request.POST or None) if formCont.is_valid(): formCont.save() error(request, 'Информация о контакте успешно добавлена.') return redirect('contact-index') var = {'formCont': formCont} return render_to_response('restaurant/contact/edit.html', var, context_instance=RequestContext(request))
def editContact(request, id): contact = Contact.objects.get(id=id) formCont = ContactForm(request.POST or None, instance=contact) if formCont.is_valid(): formCont.save() error(request, 'Информация о контакте успешно изменена.') return redirect('contact-index') var = {'contact': contact, 'formCont': formCont} return render_to_response('restaurant/contact/edit.html', var, context_instance=RequestContext(request))