Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBernardo Augusto García Loaiza
Courses Plus Student 792 PointsWhat is the difference between use SimpleRouter() and DefaultRouter() classes?
In the video about of Relations, Kenneth did:
router = routers.SimpleRouter()
router.register(r'courses', views.CourseViewSet)
router.register(r'reviews', views.ReviewViewSet)
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^api-auth/', include('rest_framework.urls',
namespace='rest_framework')),
url(r'^api/v1/courses/', include('courses.urls', namespace='courses')),
url(r'^api/v2/', include(router.urls, namespace='apiv2')),
]
And I have been serializing my models of this way:
router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r'teams', TeamViewSet)
router.register(r'fields', FieldViewSet)
router.register(r'matchs', MatchViewSet)
urlpatterns = [
url(r'^api/', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]
In this url http://www.django-rest-framework.org/api-guide/routers/ says:
This router is similar to SimpleRouter as above, but additionally includes a default API root view, that returns a response containing hyperlinks to all the list views. It also generates routes for optional .json style format suffixes.