Skip to content

Commit

Permalink
fix import cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
darius BERNARD committed Jan 6, 2017
1 parent 022ca76 commit d4a7ca6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
5 changes: 0 additions & 5 deletions rest_models/backend/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
from rest_models.backend.utils import message_from_response
from rest_models.router import RestModelRouter

from rest_models.checks import register_checks

register_checks()


logger = logging.getLogger(__name__)

Alias = namedtuple('Alias', 'model,parent,field,attrname,m2m')
Expand Down
3 changes: 1 addition & 2 deletions rest_models/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
from django.apps import apps
from django.core.checks import Error, Tags, register

from rest_models.router import RestModelRouter

logger = logging.getLogger(__name__)


def api_struct_check(app_configs, **kwargs):
from rest_models.backend.compiler import get_resource_path # NOQA
from rest_models.router import RestModelRouter # NOQA

errors = []

Expand Down
4 changes: 4 additions & 0 deletions rest_models/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
from django.db import connections

from rest_models.backend.base import DatabaseWrapper
from rest_models.checks import register_checks

logger = logging.getLogger(__name__)


register_checks()


def get_default_api_database(databases):
"""
parse all database settings and return the database matching current backend.
Expand Down
1 change: 1 addition & 0 deletions testapi/badapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __str__(self):
class BB(models.Model):
name = models.CharField(max_length=135)
b = models.ManyToManyField(B, related_name='bb')
a = models.ManyToManyField(A, related_name='bb')

def __str__(self):
return self.name # pragma: no cover
3 changes: 2 additions & 1 deletion testapi/badapi/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class Meta:

class BBSerializer(DynamicModelSerializer):
b = DynamicRelationField(BSerializer, many=True)
a = DynamicRelationField(ASerializer, many=False)

class Meta:
model = BB
name = 'bb'
fields = ('id', 'name', 'b')
fields = ('id', 'name', 'b', 'a')
1 change: 0 additions & 1 deletion testsettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
if os.environ.get('WITH_BADAPP', "false").lower().strip() == 'true'
else tuple()
)
print(INSTALLED_APPS)
DATABASE_ROUTERS = [
'rest_models.router.RestModelRouter',
]
Expand Down

0 comments on commit d4a7ca6

Please sign in to comment.