Django 版本:1.2.3
我想将 Form 对象从模板标签传递到该标签的专用视图。我的代码如下:
from django import template
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext, gettext_lazy as _
from django.conf import settings
from django.utils import simplejson
register = template.Library()
........
@register.inclusion_tag('template.html', takes_context=True)
def asset_diskencryption_settings(context, var1, form):
context["form"] = form
context["var1"] = var1
return '' // Probably I have to use some method which allows me to return some variables to the template
在 template.html 我想使用表单变量,例如 {{form.password}}