tôi có một cái nhìn như thế này:điển trong django mẫu
info_dict = [{u'Question 1': ['13365', '13344']}, {u'Question 2': ['13365']}, {u'Question 3': []}]
for key in info_dict:
for k, v in key.items():
profile = User.objects.filter(id__in=v, is_active=True)
for f in profile:
wanted_fields = ['job', 'education', 'country', 'city','district','area']
profile_dict = {}
for w in wanted_fields:
profile_dict[f._meta.get_field(w).verbose_name] = getattr(f, w).name
return render_to_response('survey.html',{
'profile_dict':profile_dict,
},context_instance=RequestContext(request))
và trong mẫu:
<ul>
{% for k, v in profile_dict.items %}
<li>{{ k }} : {{ v }}</li>
{% endfor %}
</ul>
Tôi chỉ có một từ điển trong mẫu. Nhưng 4 từ điển có thể ở đây (vì info_dict) Điều gì là sai trong quan điểm?
Cảm ơn trước
bạn đã cứu mạng tôi. Cảm ơn – TheNone
@ TheNone: crikey, sếp của bạn là * thực sự * nghiêm ngặt. Bạn được chào đón. –