Skip to content

Commit

Permalink
fix(many_to_many): fix error getting autogenerated model (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarreau committed Aug 3, 2023
1 parent 6c9ef19 commit e38803a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django_forest/resources/utils/json_api_serializer.py
@@ -1,7 +1,7 @@
from django.apps import apps
from django_forest.utils.schema import Schema
from django_forest.utils.schema.json_api_schema import JsonApiSchema
from django_forest.resources.utils.query_parameters import parse_qs
from django_forest.utils.models import Models

class JsonApiSerializerMixin:

Expand Down Expand Up @@ -41,7 +41,7 @@ def get_fields_for_collection(self, collection, required_fields=None):
collection_fields
)
)
Model = next(filter(lambda m: m._meta.db_table == collection['name'], apps.get_models()))
Model = Models.get(collection['name'])
pk_field = Model._meta.pk
if 'id' in required_fields and pk_field.name != 'id':
pk_field = next(filter(lambda f: f['field'] == pk_field.name, collection['fields']))
Expand Down

0 comments on commit e38803a

Please sign in to comment.