只有备用(偶数行)被导入到 Django 中的数据库中

Only the alternate(even rows) are getting imported into the database in django

我正在使用 django 进行 excel 文件上传 使用相同的方法,我在无法上传的第二个模型中使用 xlsx file.But 填充了另一个模型,我遇到了下面提到的问题。

views.py

def import_source(request):
    if request.method == "POST":
        form = UploadFileForm(request.POST,
                              request.FILES)
        if form.is_valid():
            request.FILES['file'].save_to_database(
                name_columns_by_row=0,
                model=Tracker,
                mapdict=['sl_no','dot','branch','sname','snum','can_name','sdetail','main_skills','uname','cus_name','ep_num','day','doi','status','cont_num','email_id','texp','rexp','cu_org','cu_loc','pref_loc','cu_ctc','exp_ctc','notice_period'])
            return HttpResponse("OK")
        else:
            return HttpResponseBadRequest()
    else:
        form = UploadFileForm()
    return render(
        request,
        'upload_form.html',
        {'form': form})

models.py

class Tracker(models.Model):
    sl_no = models.IntegerField()
    dot = models.DateTimeField()
    branch = models.CharField(max_length=200)
    sname = models.CharField(max_length=200)
    snum = models.CharField(max_length=200)
    can_name = models.CharField(max_length=200)
    sdetail = models.CharField(max_length=200)
    main_skills = models.TextField()
    uname = models.CharField(max_length=200)
    cus_name = models.CharField(max_length=200)
    ep_num = models.CharField(max_length=200,primary_key=True)
    day = models.CharField(max_length=200)
    doi = models.DateTimeField()
    status = models.CharField(max_length=200)
    cont_num = models.IntegerField()
    email_id = models.EmailField(max_length=200)
    texp = models.DecimalField(max_digits=4,decimal_places=2)
    rexp = models.DecimalField(max_digits=4,decimal_places=2)
    cu_org = models.CharField(max_length=200)
    cu_loc = models.CharField(max_length=200)
    pref_loc = models.CharField(max_length=200)
    cu_ctc = models.DecimalField(max_digits=4,decimal_places=2)
    exp_ctc = models.DecimalField(max_digits=4,decimal_places=2)
    notice_period = models.IntegerField()

Excel file .xlsx file which I'm tryig to upload

上图中只上传了sl_no1,3,5行

result enter image description here

谢谢支持!!@chfw 代码有效。 实际上问题出在 excel 文件中的日期格式。 Django 接受 yyyy-mm-dd,但输入日期的格式为 dd-mm-yyyy