コード例 #1
0
def edit(request,param):
    #IBM方法中的
    # post = project.objects(id=param)[0]
    #小稳子建议用pk替换id,pk主键的意思,据说更规范一些
    # post = project.objects(pk=param)[0]
    #小稳子建议用get
    post = project.objects.get(pk=param)
    for i in project.objects(pk=param):
        print(i)
    if request.method == 'POST':
        # update field values and save to mongo
        id = param
        name = request.POST['name']
        description = request.POST['description']
        pmember = request.POST['pmember']
        devmember = request.POST['devmember']
        testmember = request.POST['testmember']
        uimember = request.POST['uimember']
        post = project(id=param,name=name, description=description,pmember=pmember,devmember=devmember,testmember=testmember,uimember=uimember,status="测试中")
        post.last_update = datetime.now()
        post.save()
        # return index(request)
        return HttpResponseRedirect('/index/')

    # elif request.method == 'GET':
    #     templatep = 'edit.html'
    #     post = project.objects(id=param)[0]
    return render_to_response("edit.html", locals(),context_instance=RequestContext(request))
コード例 #2
0
def newproject(request):
    if request.method == 'POST' and request.POST['name'] is not None:
        name = request.POST['name']
        description = request.POST['description']
        pmember = request.POST['pmember']
        devmember = request.POST['devmember']
        testmember = request.POST['testmember']
        uimember = request.POST['uimember']
        post = project(name=name, description=description,pmember=pmember,devmember=devmember,testmember=testmember,uimember=uimember,status="测试中")
        if request.FILES:
            filename =request.FILES['proupload'].name
            uploaded_file(request.FILES['proupload'],filename)
            post.proadress = filename
        # profile = request.FILES["proupload"]
        # post.file.put(profile)
        # post.file.put(open(r'C:\\Users\min.sun\Desktop\阿布.jpg','rb'))
        post.last_update = datetime.now()
        post.save()
        return HttpResponseRedirect('/index/')

    return render_to_response('newproject.html', locals(),context_instance=RequestContext(request))
コード例 #3
0
from projectmanageapp.models import project
post=project(name='test')
post.file.put(open(r'C:\\Users\min.sun\Desktop\阿布.jpg','rb'))
post.save()