how can i get the file names from data base to list them into droplist in models.py : class FilesUpload(models.Model): file = models.FileField(null=True, blank=True,upload_to="media/") def filename(self): name = os.path.basename(self.file.name) return name
in views.py : def File_List(request): List=FilesUpload.objects.all() return render(request,"Espace_user\Espace_user.html",{'fichier':List}) in html file: <select name="Files" id="file"> {% for f in fichier %} <option value="{{f.id}}">{{ f.file.filename }}</option> {% endfor %} </select> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d665f774-f7fd-4a26-af9f-c3f4bb12fe0cn%40googlegroups.com.