该模型将保存上传的文件和上传的文件。 并且每个文件都上传到特定文件夹。因此,使用以下两个关系,我应该能够获得用户在特定批次的文件夹中上传的文件。
我需要通过关系更改关系以使用Django ManyToManyField。下面的模型关系可以适应(https://docs.djangoproject.com/en/1.9/topics/db/models/#extra-fields-on-many-to-many-relationships)。
class FileUpload(Model):
admin = ForeignKey(
User, on_delete=CASCADE, related_name='file_uploaded_by')
upload_date_time = DateTimeField(
auto_now_add=True,
blank=True,
verbose_name="Upload Date")
class FileUploadDetail(Model):
which_file = ForeignKey(
FileUpload, on_delete=CASCADE, related_name='uploaded_file')
folder_name = ForeignKey(
Folder,
on_delete=CASCADE, related_name='uploaded_to_folder')