示例#1
0
    def get(self, request, *args, **kwargs):
        _mentor_id = args[0]
        mentObj = Mentorship.objects.filter(id=_mentor_id)
        mentor = mentObj.values()[0]
        mentor['mid'] = mentObj[0].id
        mentor['batch'] = mentObj[0].batch.id
        mentor['staff'] = mentObj[0].staff.id

        form = MentorshipForm(instance=mentObj[0])
        print form

        return render(request, self.template_name, {'form': form})
示例#2
0
    def post(self, request, *args, **kwargs):
        try:
            instance = Mentorship.objects.get(id=request.POST['mid'])
            form = MentorshipForm(request.POST, instance=instance)
            mentor = form.save(commit=False)

            mentor.save()
            msg = "Record saved"
        except:
            msg = "Unable to process, Please check all values are present"
        return HttpResponse(json.dumps(dict(result=msg)),
                            content_type="application/json")
示例#3
0
    def post(self, request, *args, **kwargs):

        form = MentorshipForm(request.POST)
        mentorship = form.save(commit=True)
        return HttpResponseRedirect('/admin/mentors')