Skip to content

Commit 950f182

Browse files
committed
Refined the makeresources management command slightly to improve handling of models with names ending in 'Resource' -- tastypie requires the resource name to be explicitly set in that case.
- Legacy-Id: 17858
1 parent 5697c6e commit 950f182

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

ietf/api/management/commands/makeresources.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Meta:
4444
queryset = {{model.name}}.objects.all()
4545
serializer = api.Serializer()
4646
cache = SimpleCache()
47-
#resource_name = '{{model.resource_name}}'
47+
{% if model.rn_comment %}#resource_name = '{{model.resource_name}}'{% else %}resource_name = '{{model.resource_name}}'{% endif %}
4848
ordering = ['{{model.pk_name}}', ]
4949
filtering = { {% for name in model.plain_names %}
5050
"{{ name }}": ALL,{%endfor%}{% for name in model.fk_names%}
@@ -178,6 +178,7 @@ def handle_app_config(self, app, **options):
178178
fk_names=fk_names,
179179
m2m_names=m2m_names,
180180
pk_name=pk_name,
181+
rn_comment=False if resource_name.endswith('resource') else True,
181182
)
182183

183184
# Sort resources according to internal FK reference depth

0 commit comments

Comments
 (0)