示例#1
0
def setJob(request):
    obj = Job(owner=request.user)
    form = JobForm(request.POST, instance=obj)
    if form.is_valid(): 
        obj = form.save()
        return getJobDetail(request.user, obj.id)
    else:
        message = {'job': {'error':{ } } }
        for k, v in form.errors.iteritems():
            message['job']['error'][k] = v[0]
        return message
示例#2
0
def editJob(request):
    try:
        obj = Job.objects.get(owner=request.user, id=request.POST['id'])
    except:
        return {'job': {'error':"Job does not exist", } }
    
    form = JobForm(request.POST, instance=obj)
    if form.is_valid(): 
        obj = form.save()
        return getJobDetail(request.user, obj.id)
    else:
        message = {'job': {'error':{ } } }
        for k, v in form.errors.iteritems():
            message['job']['error'][k] = v[0]
        return message