1
model 
 class CustomerInfo(models.Model):
   customer_name = models.CharField(max_length=50)
   customer_letter= models.FileField(upload_to='/media/',null= True, blank=model 
 class CustomerInfo(models.Model):
   customer_name = models.CharField(max_length=50)
   customer_letter= models.FileField(upload_to='/media/',null=True,blank=         True)
   representative_name = models.CharField(max_length=50)
   representative_letter = models.FileField(upload_to='/media/', null=True, blank=True)
   ministry_approval = models.FileField(upload_to='/media/', null=True, blank=True)
   date = models.DateField()

   def __str__(self):
     return self.customer_name + ' - ' + self.customer_letter + ' - ' +    self.represntative_name + ' - ' + self.representative_letter + ' - ' + self.ministry_approval + ' - ' + self.date

def custmoer(request):
if request.method == 'POST':
    form = CustomerForm(request.POST, request.FILES)
    if form.is_valid():
        form.save()
        return HttpResponseRedirect('/login/custmoer/')
    else:
        return HttpResponseRedirect('/login')
else:
    form= CustomerForm()
    return render(request, "custmoer.html", {'form':form})   

表格.py

class CustomerForm(forms.ModelForm):
   class Meta:
      model = CustomerInfo
      fields = ('customer_name', 'customer_letter', 'representative_name',    'representative_letter', 'ministry_approval', 'date')
4

0 回答 0