CodeDrift
V2EX  ›  问与答

求问一个 Django Model choices 的问题

  •  
  •   CodeDrift · Apr 24, 2015 · 2365 views
    This topic created in 4062 days ago, the information mentioned may be changed or developed.

    在模型里面定义了 choices 知道在模板中可以使用 get_字段名_display来展示

    可是 我现在要在python后端写html代码传到模板中,请问要怎么使用这个choices字段呢?

    后端

    html += "<td></td><td>"
    context["html"] = html

    模板

    {{html|sate}}

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1051 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 18:05 · PVG 02:05 · LAX 11:05 · JFK 14:05
    ♥ Do have faith in what you're doing.