Django: Add arbitrary additional data to a queryset -
i trying display map of data based on search. easiest way handle map display serialized queryset generated search, , indeed works fine using . however, i'd allow multiple searches, displayed points being shown in user chosen color. user chosen color, cannot come database, since not property of these objects, none of aggregators make sense here.
i have tried making utility class, since need complex join between 2 model classes gets serialized geojson. however, once created utility class, became evident lost lot of benefits of having queryset, ability serialize data django-geojson (or natively once can 1.8 run smoothly).
basically, want able like:
queryset = datumclass.objects.filter(...user submitted search parameters...).annotate(color='blue')
is possible @ all? seems more elegant , work better current solution of non-model utility class has serious serialization issues when try use python-geojson serialize.
not quite sure trying achieve, can add attributes objects iterating on queryset in . these can accessed template.
for object in queryset : if object.contition = 'a' object.color = 'blue' else: object.color = 'green'
Comments
Post a Comment