<s> from django . template import RequestContext <EOL> from django . http import Http404 , HttpResponse <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . utils import simplejson <EOL> def filter_contenttypes_by_app ( request ) : <EOL> """<STR_LIT>""" <EOL> if not request . GET : <EOL> raise Http404 <EOL> response_list = [ { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ] <EOL> qs = request . GET . get ( '<STR_LIT>' ) <EOL> if not qs : <EOL> HttpResponse ( simplejson . dumps ( response_list ) , mimetype = '<STR_LIT>' ) <EOL> try : <EOL> content_types = ContentType . objects . filter ( app_label = qs ) <EOL> except : <EOL> raise Http404 <EOL> for ct in content_types : <EOL> response_list += [ { '<STR_LIT>' : ct . model , '<STR_LIT>' : str ( ct . pk ) } ] <EOL> return HttpResponse ( simplejson . dumps ( response_list ) , mimetype = '<STR_LIT>' ) </s>
