@login_required
def vacancy_update(request, vacancy_id=1):
obj = Vacancy.objects.get(id=vacancy_id)
form = VacancyForm(request.POST, instance=obj)
if request.method == 'POST':
if form.is_valid():
form.save(commit=False)
return HttpResponseRedirect('/accounts/profile/vacancy/all/')
else:
user = request.user
obj = Vacancy.objects.get(pk=vacancy_id)
form = VacancyForm(instance=obj)
args = {}
args.update(csrf(request))
args['form'] = form
return render_to_response('vacancy_update.html', args)
QGxvZ2luX3JlcXVpcmVkCmRlZiB2YWNhbmN5X3VwZGF0ZShyZXF1ZXN0LCB2YWNhbmN5X2lkPTEpOgogICAgb2JqID0gVmFjYW5jeS5vYmplY3RzLmdldChpZD12YWNhbmN5X2lkKQogICAgZm9ybSA9IFZhY2FuY3lGb3JtKHJlcXVlc3QuUE9TVCwgaW5zdGFuY2U9b2JqKQogICAgaWYgcmVxdWVzdC5tZXRob2QgPT0gJ1BPU1QnOgogICAgICAgIGlmIGZvcm0uaXNfdmFsaWQoKToKICAgICAgICAgICAgZm9ybS5zYXZlKGNvbW1pdD1GYWxzZSkKICAgICAgICAgICAgcmV0dXJuIEh0dHBSZXNwb25zZVJlZGlyZWN0KCcvYWNjb3VudHMvcHJvZmlsZS92YWNhbmN5L2FsbC8nKQogICAgZWxzZToKICAgICAgICB1c2VyID0gcmVxdWVzdC51c2VyCiAgICAgICAgb2JqID0gVmFjYW5jeS5vYmplY3RzLmdldChwaz12YWNhbmN5X2lkKQogICAgICAgIGZvcm0gPSBWYWNhbmN5Rm9ybShpbnN0YW5jZT1vYmopCiAgICBhcmdzID0ge30KICAgIGFyZ3MudXBkYXRlKGNzcmYocmVxdWVzdCkpCiAgICBhcmdzWydmb3JtJ10gPSBmb3JtCiAgICByZXR1cm4gcmVuZGVyX3RvX3Jlc3BvbnNlKCd2YWNhbmN5X3VwZGF0ZS5odG1sJywgYXJncyk=