I'm trying to save my images to the media root folder which I've named pictures in the media folder. This is my code and I want whenever my function is making the screenshot it should save the screenshots in my media root folder.
from django.shortcuts import render
from django.http import HttpResponse
from django.shortcuts import get_object_or_404,render,redirect
import time
import random
from django.db import models
import pyautogui
import sys
from shots.models import pictures
from .models import pictures
from shots.forms.forms import DocumentForm
def button(request):
import pyautogui
myScreenshot = pyautogui.screenshot()
storage=pictures.pictures2
myScreenshot.save(storage)
return render(request,'index.html')
def output(request):
return HttpResponse("""Hello, world. You're at the polls index.
your Screenshot should start now""")
This is my models.py:
from django.db import models
import random
class pictures(models.Model):
pub_date = models.DateTimeField('date published')
pictures2 = models.ImageField(upload_to='pictures')