在成功实现x = tf.constant(8, name = "x_const")
y = tf.constant(5, name = "y_const")
my_sum = tf.add(x,y, name = "x_y_sum")
#create the session
#this runs the default graph
with tf.Session() as sess:
print(my_sum.eval())
和crispy-forms
之后,我想到了要使用django-tables 2
在表中进行过滤,而我正在努力。
首先,我发现记录的糟糕得多,这也许就是为什么我找不到我需要的信息的原因。
我想在一个下拉菜单中选择可以用来显示django-filter
,All users
,Superusers
的天气。
因此,我已通过自定义选项从Normal users
移至BooleanFilter
。
ChoiceFilter
这就是我得到的:
为什么这些破折号在那里?如何摆脱它们?
也许我什至不需要使用class UserFilter(filters.FilterSet):
SUPERUSER_CHOICES = {
('', 'All'),
('True', 'Superusers'),
('False', 'Normal users')
}
username = filters.CharFilter(field_name='username', lookup_expr='icontains')
is_superuser = filters.ChoiceFilter(field_name='is_superuser', lookup_expr='exact',
choices=SUPERUSER_CHOICES,)
test = filters.Filter
class Meta:
model = User
fields = ['username', 'is_superuser']
来更改选项的值?
答案 0 :(得分:0)
您需要在the docs here的empty_label
上将None
设置为ChoiceFilter
:
is_superuser = filters.ChoiceFilter(
field_name='is_superuser',
lookup_expr='exact',
choices=SUPERUSER_CHOICES,
empty_label=None
)
另请参阅this answer,以更好地理解Django的empty_label
。