def pending(request): id=request.GET.get('id') a=fileupload.objects.all().order_by('id') mem=fileupload.objects.get(id=id) mem.delete() mem.close() pending = r"C:/Minorproject/minorproject/uploads/pending/" delete = r"C:/Minorproject/minorproject/uploads/delete/" for file_name in os.listdir(pending): source = pending + file_name destination = delete + file_name if os.path.isfile(source): shutil.move(source, destination) print('Moved:', file_name) mydict={"data":a} return render(request, 'college/pending.html',mydict)
class fileupload(models.Model): branch=models.CharField(max_length=100) batch=models.IntegerField() uploaddt=models.DateField(null=True) uploadby=models.CharField(max_length=100) status=models.CharField(max_length=100,default="pending") ufile=models.FileField(upload_to='uploads/pending/', null=True)
{% extends 'base.html' %} {% load static %} {% block a %} <html lang="en"> <head> <meta charset="UTF-8"> <title>Pending Files</title> </head> <body> <div class="row" style="min-height:500pxd"> <div class="col-sm-2"></div> <div class="col-sm-8 pt-5"> <table class="table table-striped table-hover"> <caption class="table caption-top">Pending table</caption> <thead> <tr> <th scope="col">ID</th> <th scope="col">File name</th> <th scope="col">File Download</th> <th scope="col">File Delete</th> <th scope="col">File Process</th> </tr> </thead> <tbody> {% for a in data %} <tr> <th scope="row">{{a.id}}</th> <td>{{a.branch}}_{{a.batch}}.csv</td> <td><a href="/{{a.ufile}}"><button class="color border border-0" >class="fa-solid fa-download fs-4"></button></a></td> <td><a href="delete/{{a.id}}"><button class="color border border-0" >^__i class="fa-solid fa-delete fs-4"></button></a></td> </tr> {% endfor %} </tbody> </table> </div> <div class="col-sm-2"></div> </div> </body> {% endblock %}
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)