Changed method of retrieving an app's models. Also now importing import_module from importlib instead of from django.

- Legacy-Id: 12531
This commit is contained in:
Henrik Levkowetz 2016-12-15 13:17:07 +00:00
parent b3740bcfca
commit cc333d9430
2 changed files with 5 additions and 4 deletions

View file

@ -133,8 +133,8 @@ def autodiscover():
may want.
"""
from importlib import import_module
from django.conf import settings
from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
for app in settings.INSTALLED_APPS:

View file

@ -1,11 +1,11 @@
import os
import sys
import json
from importlib import import_module
from django.apps import apps
from django.test import Client
from django.conf import settings
from django.utils.importlib import import_module
from django.db import models
from tastypie.exceptions import BadRequest
from tastypie.test import ResourceTestCaseMixin
@ -82,7 +82,8 @@ class TastypieApiTestCase(ResourceTestCaseMixin, TestCase):
self.assertValidJSONResponse(r)
app_resources = json.loads(r.content)
self._assertCallbackReturnsSameJSON("/api/v1/%s/"%name, app_resources)
model_list = models.get_models(app.models)
#
model_list = apps.get_app_config(name).get_models()
for model in model_list:
if not model._meta.model_name in app_resources.keys():
#print("There doesn't seem to be any resource for model %s.models.%s"%(app.__name__,model.__name__,))