0

'''

我的问题是数据库值无法正确存储在下面我上传了视图函数文件,模型文件作为图像。所以在模型中有三个字段,但数据库只存储图像存储和默认存储的其他 vlaues 获取空值所以你能帮助解决我的问题..

'''

用户问题.html

<form method="POST" action="/uploadoc/" enctype="multipart/form-data" data-toggle="validator">
                                {% csrf_token %}
                                <div id="progressbarwizard">
                                    <ul class="nav nav-pills bg-light nav-justified form-wizard-header mb-3">
                                        <li class="nav-item">
                                            <a href="#account-2" data-toggle="tab" class="nav-link rounded-0 pt-2 pb-2">
                                                <i class="mdi mdi-account-circle mr-1"></i>
                                                <span class="d-none d-sm-inline">Query Form</span>
                                            </a>
                                        </li>

                                    </ul>

                                    <div class="tab-content b-0 mb-0">
                                        <div class="tab-pane" id="account-2">
                                             <div class="row">
                                                 <div class="col-md-5">
                                                     <label class="col-md-12 col-form-label">Query Types:
                                                    <span class="text-danger">*</span></label>
                                                        <div class="col-md-8">
                                                            <input type="text" class="form-control" data-validate="true"  name="queryn" placeholder="Enter Query Types">
                                                        </div>
                                             </div>
                                                 <div class="col-md-5">
                                                     <label class="col-md-12 col-form-label">Description of Query:
                                                    <span class="text-danger">*</span></label>
                                                        <div class="col-md-12">
                                                            <textarea type="text" class="form-control" data-validate="true"  name="querydec" placeholder="Description of Query"></textarea>
                                                        </div>
                                                 </div>

                                            </div><!-- /.First row end --><br>
                                             <div class="row">

                                                <div class="col-md-5">
                                                    <label for="Emailadrress" class="col-md-12 col-form-label">Upload Your File:
                                                    <span class="text-danger"></span></label>
                                                        <div class="col-md-12">
                                                            <div class="input-group-append">
                                                                  <input type="file" id="img" name="img" accept="image/*">

                                                            </div>
                                                        </div>
                                                </div>
                                                <div class="col-md-6">
                                                    <label for="Emailadrress" class="col-md-12 col-form-label">Solutions:
                                                    <span class="text-danger"></span></label>
                                                        <div class="col-md-12">
                                                            <div class="input-group-append">
                                                            <textarea type="text"   name="querysol" placeholder="Solutions of Query"></textarea>

                                                            </div>
                                                        </div>
                                                </div>

                                            </div> <!-- /.second row end -->

                                        </div><br>


                                            <div class="row">
                                                <div class="col-12">
                                                    <div class="text-center">
                                                        <div class="mb-3">
                                                            <div class="custom-control custom-checkbox">
                                                                <input type="checkbox" class="custom-control-input" id="customCheck3">
                                                                <button type="submit" class="btn btn-primary">
                                                                  <i class="icon-user icon-white"></i> Submit
                                                                </button>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div> <!-- end col -->

                                        </div>

                                    </div>                                    </div> 
                            </form>

'[这是错误并查看我的模型图像页面的功能文件][1]

4

1 回答 1

0

您正在尝试从视图中的命名 POST 数据中设置c变量。userProblemModeluploadoc

c = request.POST.get('userProblemModel')

但是在您的 html 表单中,没有userProblemModel命名输入标记。这就是为什么你在变量中获得None价值。c

于 2020-04-09T13:32:47.023 回答