R
R
Rassul Nassyrov2020-09-11 18:09:51
Django
Rassul Nassyrov, 2020-09-11 18:09:51

Why are the photos not saved to a folder?

Photos are saved when you change them through the database. And when changes are made by the user on the site, they change in the database but are not saved to the static/images folder.

Settings.py:

STATIC_URL = '/static/'

MEDIA_URL = '/images/'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

MEDIA_ROOT = os.path.join(BASE_DIR, 'static/images')


Views.py:
if request.method == "POST":
        for i in isauthedbool:
            if i.account_login == login_for_redirect:
                redact_base = account.objects.get(account_login = i.account_login)
                redact_base.account_image = request.POST['file']
                redact_base = redact_base.save()
                return render(request, "frontend/profile.html", {'isauthed_for_html': isauthed_for_html,'isauthedbool': isauthedbool, 'login_for_redirect': login_for_redirect})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-09-11
@nssr02

redact_base.account_image = request.POST['file']where did this code come from?
read the docs https://docs.djangoproject.com/en/3.1/topics/http/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question