<commit_before>from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotAllowed, Http404, QueryDict
from django.db.models import DateField, DateTimeField, BooleanField
from django.db.models.fields.related import ForeignKey, ManyToManyField
from django.shortcuts import get_object_or_404, render
from django.core.urlresolvers import reverse
from django.conf import settings
import csv, json, datetime, lxml, urllib
import dateutil.parser

from simplegetapi.utils import is_enum, enum_key_to_value, enum_get_values, get_orm_fields
from simplegetapi.serializers import serialize_object, serialize_response_json_data, serialize_response_json, serialize_response_jsonp, serialize_response_xml, serialize_response_csv

def get_api_models():
    if not hasattr(settings, 'API_MODELS') or not isinstance(settings.API_MODELS, dict):
        raise Exception("The API_MODELS setting is not configured.")

    def resolve_model_name(model_name):
        from django.apps import apps # Django 1.7+
        try:
            app_label, model_name = model_name.split('.', 1)
            return apps.get_model(app_label=app_label, model_name=model_name)
        except:
            raise Exception("The API_MODELS setting is not configured properly. Invalid model: %s" % model_name)<commit_msg>Django 2.0 fixes<commit_after>from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseNotAllowed, Http404, QueryDict
from django.db.models import DateField, DateTimeField, BooleanField
from django.db.models.fields.related import ForeignKey, ManyToManyField
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.conf import settings
import csv, json, datetime, lxml, urllib
import dateutil.parser

from simplegetapi.utils import is_enum, enum_key_to_value, enum_get_values, get_orm_fields
from simplegetapi.serializers import serialize_object, serialize_response_json_data, serialize_response_json, serialize_response_jsonp, serialize_response_xml, serialize_response_csv

def get_api_models():
    if not hasattr(settings, 'API_MODELS') or not isinstance(settings.API_MODELS, dict):
        raise Exception("The API_MODELS setting is not configured.")

    def resolve_model_name(model_name):
        from django.apps import apps # Django 1.7+
        try:
            app_label, model_name = model_name.split('.', 1)
            return apps.get_model(app_label=app_label, model_name=model_name)
        except:
            raise Exception("The API_MODELS setting is not configured properly. Invalid model: %s" % model_name)
{'fraction_non_alphanumeric': 0.0673374613003096, 'fraction_numerical': 0.007739938080495356, 'mean_word_length': 5.2590799031477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6500567', 'n_tokens_mistral': 747, 'n_tokens_neox': 726, 'n_words': 205}