小编Dik*_*sha的帖子

fa-user-circle-o 不工作

我想显示用户圆圈图标,我已经下载了一个字体很棒的 css 文件,版本为 4.7.0。但这对我不起作用。如果我使用 cdn 那么它的工作。我不明白下载的文件有什么问题。这是我的代码:

<html>
    <head>
        <link href="font-awesome.min.css" rel="stylesheet" type="text/css">
    </head>
    <body>
        <i class="fa fa-user-circle-o"></i>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

有谁知道是什么问题?

html font-awesome

6
推荐指数
1
解决办法
9277
查看次数

读取文件时<<:'str'和'int'不受支持的操作数类型

我正在编写单元测试用例.我创建一个文件对象并读取它,但我收到以下错误:

<<:'str'和'int'不受支持的操作数类型

方法:

def uploadExamineeDetails(request, exam_id):
    try:
        upload_file = request.FILES['upload-file']
    except Exception:
        return [_('Uploaded file is required.')]
    try:
        exam = get_object_or_404_from_admin(CourseExam, request, exam_id)
        book = xlrd.open_workbook(file_contents=upload_file.read())
        # further code
Run Code Online (Sandbox Code Playgroud)

我的测试代码:

def test_uploadExamineeDetails(self):

    self.examinee_result = os.path.join(os.path.dirname(settings.BASE_DIR),\
                                        'var/sample_files_for_testing/examinees_result_upload.xls')
    file = File(open(self.file, errors='ignore'))
    uploaded_file = InMemoryUploadedFile(file=file, field_name='upload-file', name='examinee_result.xls',
                                        content_type = 'application/vnd.ms-excel', size = file.size, charset = None)
    self.request.FILES['upload-file'] = uploaded_file
    xlrd.open_workbook(file_contents=uploaded_file.read())
    response = uploadExamineeDetails(self.request, 1)
    assert isinstance(response, tuple), 'should upload the examinee details'
Run Code Online (Sandbox Code Playgroud)

excel文件中的数据:

[{'Enrollment Number': '', 'Username': 'exam_course_manager',
 'row_num': 1, 'Obtained Score': …
Run Code Online (Sandbox Code Playgroud)

python django pytest

3
推荐指数
1
解决办法
1333
查看次数

为什么带有auto_now_add的DateTimeField无法进入表单字段

以下是我的模型:

class MyModel(models.Model):
    code = models.CharField(_('Code'), max_length=56, null=False,
                        blank=False, db_column='code')
    name = models.CharField(_('Name'), max_length=128, null=False,
                        db_index=True, db_column='name', blank=False)
    created_at = models.DateTimeField(_('Created At'), null=False,
                                      db_column='created_at', blank=False,
                                      auto_now_add=True)
Run Code Online (Sandbox Code Playgroud)

形成:

class MyForm(forms.Form):
    class Meta:
        model = MyModel 
        fields = '__all__'
Run Code Online (Sandbox Code Playgroud)

视图

class MyView(View):

    def get(self, request):
        form = MyForm(request=request)
        return render(request, 'test_manager/testrule_form.html', {'form': form})
Run Code Online (Sandbox Code Playgroud)

显示此表单时,我可以看到除created_at之外的所有字段。有谁知道在更新某些对象时如何获取created_at字段?

python django django-forms

2
推荐指数
1
解决办法
583
查看次数

标签 统计

django ×2

python ×2

django-forms ×1

font-awesome ×1

html ×1

pytest ×1