fix api.template.py to work with swagger
diff --git a/planetstack/apigen/api.template.py b/planetstack/apigen/api.template.py
index 9edaaa2..1f2c3a5 100644
--- a/planetstack/apigen/api.template.py
+++ b/planetstack/apigen/api.template.py
@@ -217,7 +217,9 @@
filter_fields = ({% for prop in object.props %}'{{ prop }}',{% endfor %}{% for ref in object.refs %}{%if ref.multi %}'{{ ref.plural }}'{% else %}'{{ ref }}'{% endif %},{% endfor %})
def get_serializer_class(self):
- no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
+ no_hyperlinks=False
+ if hasattr(self.request,"QUERY_PARAMS"):
+ no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
if (no_hyperlinks):
return self.id_serializer_class
else:
@@ -253,12 +255,14 @@
id_serializer_class = {{ object.camel }}IdSerializer
def get_serializer_class(self):
- no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
+ no_hyperlinks=False
+ if hasattr(self.request,"QUERY_PARAMS"):
+ no_hyperlinks = self.request.QUERY_PARAMS.get('no_hyperlinks', False)
if (no_hyperlinks):
return self.id_serializer_class
else:
return self.serializer_class
-
+
def get_queryset(self):
return {{ object.camel }}.select_by_user(self.request.user)