... [ dict ( zip ( columns , row )) for row in cursor . fetchall ()] 別の選択肢は Python 標準ライブラリに含まれる collections.namedtuple() を利用する事です。 namedtuple は属性を指定して値へのアクセスが可能なタプルに似たオブジェクトです; 加えてインデックスが利 ... レート可能でもあります。取得した結果は不変であり属性名もしくはインデックスでアクセスできて便利です: from collections import namedtuple def namedtuplefetchall ( cursor ): """ Return all rows from a cursor as a namedtuple. Assume the column names are unique. ... """ desc = cursor . description nt_result = namedtuple ( "Result" , [ col [ 0 ] for col in desc ]) return [ nt_result ( * row ) for row in cursor . fetchall ()] dictfetchall() と ... ... 呼んでいます。 {% regroup %} produces a list (in this case, country_list ) of group objects . Group objects are instances of namedtuple() with two fields: grouper -- グループ分けに使われた要素 ( ここでは "India" "Japan" といった文字列 ) list -- このグループ内 ... のすべての要素からなるリスト ( たとえば country='India' であるすべての都市のリスト) Because {% regroup %} produces namedtuple() objects, you can also write the previous example as: {% regroup cities by country as country_list %} < ul > {% for count ... ... ings, the optional C implementation can return a bytestring. This was fixed in Python 2.7. simplejson.JSONEncoder gained a namedtuple_as_object keyword argument in version 2.2. More information on these incompatibilities is available in ticket #18023 . The ... ... ackend now supports context processors by setting the 'context_processors' option in OPTIONS . The regroup tag now returns namedtuple s instead of dictionaries so you can unpack the group object directly in a loop, e.g. {% for grouper, list in regrouped %} ... ... , flat = True ) . order_by ( "id" ) <QuerySet [1, 2, 3, ...]> 複数のフィールドがある場合に flat を渡すとエラーになります。 namedtuple() : として結果を得るには、 named=True を渡します: >>> Entry . objects . values_list ( "id" , "headline" , named = True ) < ... 2026年10月08日