【问题标题】:How to include HTML header tags in Django Crispy Forms?如何在 Django Crispy Forms 中包含 HTML 标题标签?
【发布时间】:2013-01-10 20:41:36
【问题描述】:

我有以下 HTML 片段,我想将其翻译成 django 格式:

    <div class="span5">
        <h3 class='offset1'>Select images</h3>
        <div id='image-drop' class='dropzone span5 center'>
            <p>Drag and drop photos and video here</p>
            <p class='big'>+</p>
            <p>Or click to add using the file browser</p>
        </div>
    </div>

我将如何包含标签和

标签?我试过这个:

    self.helper.layout = Layout(
        Div(css_class='span5',
            HTML("<h3 class='offset1'>Select Images</h3>"),
            Div(css_id='image-drop',
                css_class='dropzone span5 center',
                HTML("<p>Drag and drop photos and video here</p><p class='big'>+</p><p>Or click to add using the file browser</p>")
                )
            )
        )

但这给出了一个 SyntaxError: non-keyword arg after keyword arg --> 指向带有 HTML 字段的行。包括 HTML 在内的 Div 有什么问题吗?如何翻译给定的 HTML?

【问题讨论】:

    标签: django django-crispy-forms


    【解决方案1】:

    错误信息很清楚,不是吗?

    例如,您的内部块应该看起来像这样 (**args* fist, then ***kwargs*):

    Div(
        HTML("<p>Drag and drop photos and video here</p><p class='big'>+</p><p>Or click to add using the file browser</p>"),
        css_id='image-drop',
        css_class='dropzone span5 center'
    )
    

    【讨论】:

    • 谢谢,但不,我不太清楚这个信息。您的回复无需讽刺,这对学习社区不利。
    • 对不起,我真的不是故意无礼的。我仍然坚持认为错误消息提供了指向错误根源的明确指针SyntaxError: non-keyword arg after keyword arg。因此,如果您将错误消息变成一个问题并询问在有问题的代码块中的哪个位置,非关键字参数是否跟在参数后面? 您就快到了。至少这就是我所做的一切。
    猜你喜欢
    • 2016-01-03
    • 2021-08-29
    • 2012-07-05
    • 2012-11-09
    • 2015-12-26
    • 2021-09-24
    • 2019-08-12
    • 2021-05-29
    • 2012-12-12
    相关资源
    最近更新 更多