I am working on an upload post page which includes images. When I am on the update page I want my previously uploaded photo to be chosen already in the file-upload field.
I am doing this in my html file but it is not working
<div class="qq-uploader-buttonText-value">
<input type="file" id="input_22" name="photo1" class="form-control-file" data-imagevalidate="yes" data-file-accept="pdf, doc, docx, xls, xlsx, csv, txt, rtf, html, zip, mp3, wma, mpg, flv, avi, jpg, jpeg, png, gif" data-file-maxsize="10854" data-file-minsize="0" data-file-limit="" value="{{Post.photo1.url}}" data-component="fileupload" />
</div>
views.py
import random
from django.shortcuts import redirect, render
from django.http import HttpResponse
from home.models import Posts
@login_required(login_url='login')
def update(request, posts_id):
Post = Posts.objects.get(postid=posts_id)
context = {'Post':Post,'cod':usrid}
return render(request, 'update.html', context)
urls.py
from django.contrib.auth import logout
from django.urls import path
from . import views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('update/<str:posts_id>/',views.update,name="update"),
] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
Can anyone help me how I do this?