<commit_before># -*- coding: utf-8 -*-
import re
from django.utils import simplejson
from django.http import HttpResponse
from django.contrib.admin.views.decorators import staff_member_required
from foreignkeysearch import registered_handlers

@staff_member_required
def search(request, handler):
    h = registered_handlers.get(handler, None)
    if h is None:
        return HttpResponse(
             simplejson.dumps({}),
             mimetype='application/json'
        )

    related_field_name = h.db_field.name
<commit_msg>ajax search not csrf-aware any more<commit_after># -*- coding: utf-8 -*-
import re
from django.utils import simplejson
from django.http import HttpResponse
from django.contrib.admin.views.decorators import staff_member_required
from django.views.decorators.csrf import csrf_exempt
from foreignkeysearch import registered_handlers

@staff_member_required
@csrf_exempt
def search(request, handler):
    h = registered_handlers.get(handler, None)
    if h is None:
        return HttpResponse(
             simplejson.dumps({}),
             mimetype='application/json'
        )

    related_field_name = h.db_field.name

{'fraction_non_alphanumeric': 0.0808695652173913, 'fraction_numerical': 0.0017391304347826088, 'mean_word_length': 3.6979591836734693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5225405', 'n_tokens_mistral': 325, 'n_tokens_neox': 324, 'n_words': 86}