示例#1
0
def add_assets(request):
    if request.method == "POST":
        form = AssetsForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('assets'))
    else:
        form = AssetsForm()
    return render_to_response('assets/add_assets.html', locals(), RequestContext(request))
示例#2
0
def edit_assets(request, ID):
    the_asset = Assets.objects.get(id=ID)
    if request.method == "POST":
        form = AssetsForm(request.POST, instance=the_asset)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('assets'))
    else:
        form = AssetsForm(instance=the_asset)
    return render_to_response('assets/edit_assets.html', locals(), RequestContext(request))