CodeDrift
V2EX  ›  问与答

求问一个 Django Model choices 的问题

  •  
  •   CodeDrift · Apr 24, 2015 · 2368 views
    This topic created in 4065 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   ·   5156 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:29 · PVG 17:29 · LAX 02:29 · JFK 05:29
    ♥ Do have faith in what you're doing.