def photo_page_post(recruit_instance, request): # TeamRome if recruit_instance: form = UploadImgForm(request.POST, request.FILES) if form.is_valid(): img = form.cleaned_data.get('img') recruit_instance.img = img recruit_instance.save()
def photo_page_post(client_instance, request): # TeamRome """" views.py ClientEditPhoto(TemplateView) POST method. В БД сохраняется УНИКАЛЬНОЕ имя картинки (пр: user_2_EntrmQR.png) в папке MEDIA_URL = '/media/' """ form = UploadImgForm(request.POST, request.FILES) if form.is_valid(): img = form.cleaned_data.get('img') client_instance.img = img client_instance.save()
def photo_page_post(client_instance, request): """" views.py ClientEditPhoto(TemplateView) POST method. В БД сохраняется УНИКАЛЬНОЕ имя картинки (пр: user_2_EntrmQR.png) в папке MEDIA_URL = '/media/' """ print("photo_page_post()") time_0 = perf_counter() form = UploadImgForm(request.POST, request.FILES) if form.is_valid(): img = form.cleaned_data.get('img') client_instance.img = img client_instance.save() print('photo_page_post() - OK; TIME: %s' % (perf_counter() - time_0))
def get(self, request, *args, **kwargs): client_instance = client_check(request.user) response = {'client_img': load_client_img(client_instance), 'form': UploadImgForm(), } return render(request=request, template_name=self.template_name, context=response)