def edit_project(request, project_id): project = get_object_or_404(Project, id=project_id) form = EditProjectForm(request.POST or None, instance=project) if form.is_valid(): instance = form.save() return redirect(instance.get_absolute_url()) base_url = Preference.objects.get_preference("projects_directory", '') return render_to_response("project/project_edit_form.html", RequestContext(request, {'form': form, 'base_url': base_url}))
def edit_project(request, slug): project = get_object_or_404(Project, slug=slug) users = get_user_dicts(project) context = {'project_form': EditProjectForm(instance=project), 'users': users} if request.method == 'POST': project_form = EditProjectForm(request.POST, instance=project) if project_form.is_valid(): project.save() return redirect('projects') context['project_form'] = project_form return render(request, 'edit_project.html', context)
def edit(request, id): if request.method == 'GET': if id: project = Project.objects.get(pk=id) form = EditProjectForm(instance=project) return render(request, 'project/edit.html', { 'form': form, 'pid': id }) elif request.method == 'POST': project = Project.objects.get(pk=id) form = EditProjectForm(request.POST) if form.is_valid(): project.name = form.cleaned_data['name'] project.describe = form.cleaned_data['describe'] project.status = form.cleaned_data['status'] project.save() return redirect('/project/list/')