Skip to content

Commit b8e92d3

Browse files
committed
Added generation of Meta.ordering for API ModelResources in mkresources.
- Legacy-Id: 16283
1 parent 565c55a commit b8e92d3

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

ietf/api/management/commands/makeresources.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Copyright The IETF Trust 2014-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
13
from __future__ import print_function
24

35
import os
@@ -37,6 +39,7 @@ class Meta:
3739
serializer = api.Serializer()
3840
cache = SimpleCache()
3941
#resource_name = '{{model.resource_name}}'
42+
ordering = ['{{model.pk_name}}', ]
4043
filtering = { {% for name in model.plain_names %}
4144
"{{ name }}": ALL,{%endfor%}{% for name in model.fk_names%}
4245
"{{ name }}": ALL_WITH_RELATIONS,{%endfor%}{% for name in model.m2m_names %}
@@ -92,6 +95,7 @@ def handle_app_config(self, app, **options):
9295
plain_names = []
9396
fk_names = []
9497
m2m_names = []
98+
pk_name = model._meta.pk.name
9599
#debug.pprint('dir(model)')
96100
for field in model._meta.fields:
97101
if isinstance(field, (models.ForeignKey, models.OneToOneField)):
@@ -167,6 +171,7 @@ def handle_app_config(self, app, **options):
167171
plain_names=plain_names,
168172
fk_names=fk_names,
169173
m2m_names=m2m_names,
174+
pk_name=pk_name,
170175
)
171176

172177
# Sort resources according to internal FK reference depth

0 commit comments

Comments
 (0)