示例#1
0
router.register(r'projects', ProjectViewset)
router.register(r'project-types', ProjectTypeViewset)

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^entries/(?P<entry_pk>[^/.]+)/suggested/$',
        EntryViewSet.as_view({'get': 'list'}),
        name='entry-suggested'),
    url(r'entries/(?P<entry_pk>[^/.]+)/blog$',
        BlogViewSet.as_view({'get': 'retrieve'}),
        name='entry-blog'),
    url(r'entries/(?P<entry_pk>[^/.]+)/comments$',
        CommentViewSet.as_view({'get': 'list'}),
        name='entry-comments'),
    url(r'entries/(?P<entry_pk>[^/.]+)/authors$',
        AuthorViewSet.as_view({'get': 'list'}),
        name='entry-authors'),
    url(r'entries/(?P<entry_pk>[^/.]+)/featured$',
        EntryViewSet.as_view({'get': 'retrieve'}),
        name='entry-featured'),
    url(r'^authors/(?P<pk>[^/.]+)/(?P<related_field>\w+)/$',
        AuthorViewSet.as_view({'get': 'retrieve_related'}),
        name='author-related'),
    url(r'^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$',
        EntryRelationshipView.as_view(),
        name='entry-relationships'),
    url(r'^blogs/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$',
        BlogRelationshipView.as_view(),
        name='blog-relationships'),
    url(r'^comments/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)$',
        CommentRelationshipView.as_view(),
示例#2
0
 def _get_view(self, kwargs):
     factory = APIRequestFactory()
     request = Request(
         factory.get('', content_type='application/vnd.api+json'))
     return AuthorViewSet(request=request, kwargs=kwargs)
router.register(r'projects', ProjectViewset)

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^entries/(?P<entry_pk>[^/.]+)/suggested/',
        EntryViewSet.as_view({'get': 'list'}),
        name='entry-suggested'
        ),
    url(r'entries/(?P<entry_pk>[^/.]+)/blog',
        BlogViewSet.as_view({'get': 'retrieve'}),
        name='entry-blog'),
    url(r'entries/(?P<entry_pk>[^/.]+)/comments',
        CommentViewSet.as_view({'get': 'list'}),
        name='entry-comments'),
    url(r'entries/(?P<entry_pk>[^/.]+)/authors',
        AuthorViewSet.as_view({'get': 'list'}),
        name='entry-authors'),
    url(r'entries/(?P<entry_pk>[^/.]+)/featured',
        EntryViewSet.as_view({'get': 'retrieve'}),
        name='entry-featured'),

    url(r'^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
        EntryRelationshipView.as_view(),
        name='entry-relationships'),
    url(r'^blogs/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
        BlogRelationshipView.as_view(),
        name='blog-relationships'),
    url(r'^comments/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
        CommentRelationshipView.as_view(),
        name='comment-relationships'),
    url(r'^authors/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
示例#4
0
     CommentViewSet.as_view({"get": "list"}),
     name="entry-comments",
 ),
 re_path(
     r"^entries/(?P<entry_pk>[^/.]+)/suggested/$",
     EntryViewSet.as_view({"get": "list"}),
     name="entry-suggested",
 ),
 re_path(
     r"^drf-entries/(?P<entry_pk>[^/.]+)/suggested/$",
     DRFEntryViewSet.as_view({"get": "list"}),
     name="drf-entry-suggested",
 ),
 re_path(
     r"entries/(?P<entry_pk>[^/.]+)/authors$",
     AuthorViewSet.as_view({"get": "list"}),
     name="entry-authors",
 ),
 re_path(
     r"entries/(?P<entry_pk>[^/.]+)/featured$",
     EntryViewSet.as_view({"get": "retrieve"}),
     name="entry-featured",
 ),
 re_path(
     r"^authors/(?P<pk>[^/.]+)/(?P<related_field>[-\w]+)/$",
     AuthorViewSet.as_view({"get": "retrieve_related"}),
     name="author-related",
 ),
 re_path(
     r"^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>[\-\w]+)$",
     EntryRelationshipView.as_view(),
router.register(r'project-types', ProjectTypeViewset)

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^entries/(?P<entry_pk>[^/.]+)/suggested/',
        EntryViewSet.as_view({'get': 'list'}),
        name='entry-suggested'
        ),
    url(r'entries/(?P<entry_pk>[^/.]+)/blog',
        BlogViewSet.as_view({'get': 'retrieve'}),
        name='entry-blog'),
    url(r'entries/(?P<entry_pk>[^/.]+)/comments',
        CommentViewSet.as_view({'get': 'list'}),
        name='entry-comments'),
    url(r'entries/(?P<entry_pk>[^/.]+)/authors',
        AuthorViewSet.as_view({'get': 'list'}),
        name='entry-authors'),
    url(r'entries/(?P<entry_pk>[^/.]+)/featured',
        EntryViewSet.as_view({'get': 'retrieve'}),
        name='entry-featured'),

    url(r'^authors/(?P<pk>[^/.]+)/(?P<related_field>\w+)/$',
        AuthorViewSet.as_view({'get': 'retrieve_related'}),
        name='author-related'),

    url(r'^entries/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
        EntryRelationshipView.as_view(),
        name='entry-relationships'),
    url(r'^blogs/(?P<pk>[^/.]+)/relationships/(?P<related_field>\w+)',
        BlogRelationshipView.as_view(),
        name='blog-relationships'),