@require_GET
def ajax_status(request):
 if (not request.user.is_authenticated()):
  raise PermissionDenied
 qs = UserPreference.objects.filter(user=request.user, key=NOTIFICATION_PREF_KEY)
 return HttpResponse(json.dumps({'status': len(qs)}), content_type='application/json')

@ require_GET def ajax_status ( request ) : if ( not request . user . is_authenticated ( ) ) : raise PermissionDenied qs = UserPreference . objects . filter ( user = request . user , key = NOTIFICATION_PREF_KEY ) return HttpResponse ( json . dumps ( { 'status' : len ( qs ) } ) , content_type = 'application/json' )
a view that retrieves notifications status for the authenticated user .