2

我有以下 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 片段?

4

1 回答 1

5

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

因此,例如,您的内部块可能看起来像这样(**args* 拳头,然后 ***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'
)
于 2013-01-10T21:10:38.673 回答