Hi,
Thank you for giving that tutorial. I almost successfully implemented it in my project.
One thing about tutorial is in ViewSet your example was:
serializer = serializers.TaskSerializer(instance=tasks.values(), many=True)
But, in Python 3 it should be:
serializer = serializers.TaskSerializer(instance=list(tasks.values()), many=True)
All in all, great tutorial.
One thing, I couldnt manage to do, is understand, what is API Root and why my urls are not working properly. Could you give me a suggestion?
I have URL's like this:
# in app/urls.py
api_urls = [
url(r'promotions/', include('promotions.urls', namespace='promotions')),
]
urlpatterns = [
url(r'^api/', include(api_urls)),
]
# in promotions/urls.py
from rest_framework.routers import SimpleRouter
from .views import PromotionViewSet
router = SimpleRouter()
router.register(r'', PromotionViewSet, base_name='promotions')
urlpatterns = router.urls
But when I open in browser: http://localhost:8000/api/promotions/ it shows nothing more than empty link object in DRF response.
Although, when I change:
router.register(r'', PromotionViewSet, base_name='promotions')
to this:
router.register(r'test', PromotionViewSet, base_name='promotions')
Then I can successfully open: http://localhost:8000/api/promotions/test and see correct response.
Is there something I am missing? Probably some API Root, because in the first case, when I open the page, I see title "API Root".
I have no decorators added to any of views.
Regards, Daniels