<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , unicode_literals <EOL> from django . http import JsonResponse <EOL> from django . utils . encoding import smart_text <EOL> from django_select2 . views import AutoResponseView <EOL> class Select2ResponseView ( AutoResponseView ) : <EOL> """<STR_LIT>""" <EOL> def get ( self , request , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . widget = self . get_widget_or_404 ( ) <EOL> self . term = kwargs . get ( '<STR_LIT>' , request . GET . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . object_list = self . get_queryset ( ) <EOL> context = self . get_context_data ( ) <EOL> label_fn = self . widget . label_from_instance if hasattr ( self . widget , '<STR_LIT>' ) else smart_text <EOL> return JsonResponse ( { <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT:text>' : label_fn ( obj ) , <EOL> '<STR_LIT:id>' : obj . pk , <EOL> } <EOL> for obj in context [ '<STR_LIT>' ] <EOL> ] , <EOL> } ) </s>
