Multiple PDF file should upload,along with pdf file selected client and process should dispalay

[亡魂溺海] 提交于 2019-12-24 21:34:52

问题


Uploaded pdf file is showing correctly but selected client is not showing,Client will displayed in dropdown,if we select particular client and upload multiple pdf files,the selected client and files should display.

models.py

class Client_files(models.Model):
    Date = models.DateTimeField(default=datetime.now, blank=True)
    client = models.ForeignKey(Client, on_delete=models.CASCADE,null=True)
    client_process = models.ForeignKey(Client_Process, on_delete=models.CASCADE,null=True)
    File_Name = models.FileField()
    Pages = models.IntegerField(null=True)
    Count = models.IntegerField(null=True)
    Status = models.BooleanField(default = False)

    class Meta:
        db_table : 'client_files'

class Client(models.Model):
    Name = models.CharField(max_length=50, unique=True)
    def __str__(self):
        return self.Name
    class Meta:
        db_table : 'client'

class Client_Process(models.Model):
    process = models.ForeignKey(Process, on_delete=models.CASCADE)
    client = models.ForeignKey(Client, on_delete=models.CASCADE)
    class Meta:
        db_table : 'client_process'

views.py

def upload_files(request):
    pdf1 = Client_files.objects.all()
    print(pdf1)
    client = Client.objects.all()
    process = Client_Process.objects.all()
    print(process)
    print(client)
    if request.method == 'POST':
        form = Upload_files(request.POST,request.FILES)
        pdf = Client_files.objects.all()
        if form.is_valid():

            for file in request.FILES.getlist('File_Name'):
                Client_files.objects.create(File_Name=file)
            return redirect('/pdf/upload/')
            form.save()
    else:
        form = Upload_files()
    return render(request,'upload_file.html',{'form':form,'pdf1':pdf1,'client':client,'process':process,})

来源:https://stackoverflow.com/questions/57720832/multiple-pdf-file-should-upload-along-with-pdf-file-selected-client-and-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!