4👍
✅
If you need the new entry point to be listed, you’ll need to inherit from a ViewSet (note that I’m not speaking about ModelViewSet).
I wrote a short guide + sample project on how to do that here: https://medium.com/@linovia/django-rest-framework-viewset-when-you-don-t-have-a-model-335a0490ba6f
You won’t need all the ViewSet methods, probably just the list one according to your comments.
0👍
in your urls.py, you’re giving router.register() a DistanceView, which is of type APIView, But you’ll have to specify a ViewSet for that.
django-rest-framework can only determine url mapping for ViewSets. So instead you can manually map the url, like you would do with default django apps.
urls.py
urlpatterns = [
url(r'distance', views.DistanceView),
]
- [Django]-Attribute Error: 'dict' object has no attribute 'endswith'
- [Django]-How can I use a Django template tag for greater than on a forloop.counter?
Source:stackexchange.com