파일삭제2 [django] input[type=file] 을 이용하여 첨부한 파일 저장 views.py import os def programdetailupdate(request: HttpRequest, pk: int) -> HttpResponse: std = Program() srd = Program.objects.get(id=pk) std.pk = pk if request.FILES['pimg']: uploaded_file = request.FILES['pimg'] file_name = uploaded_file.name # 현재 날짜 가져오기 curdt = datetime.now() curdty = curdt.year curdtm = curdt.month curdtd = curdt.day mloc = f'laboratory/program/{curdty}/{curdtm}/{curdtd}'.. 2023. 5. 11. [django] DB에 담긴 파일 삭제 urls.py from django.conf.urls.static import static from django.conf import settings from . import views urlpatterns = [ path('program/pimgdelete/', views.pimgdelete, name='pimgdelete'), ] views.py def pimgdelete(request): pk = request.POST.get('pk') fieldname = request.POST.get('fieldname') if pk is None: result = HttpResponse('pk is nothing') elif fieldname is None: result = HttpResponse('field.. 2023. 5. 11. 이전 1 다음