How to use the djangorestframework.views.InstanceModelView.as_view function in djangorestframework

To help you get started, we’ve selected a few djangorestframework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github diefenbach / django-lfs / lfs / catalog / api / urls.py View on Github external
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from handlers import ProductResource

urlpatterns = patterns('',
    url(r'^products/$', ListOrCreateModelView.as_view(resource=ProductResource)),
    url(r'^product/(?P[^/]+)/$', InstanceModelView.as_view(resource=ProductResource)),
)
github encode / django-rest-framework / examples / blogpost / urls.py View on Github external
def comments(self, instance):
        return reverse('comments', kwargs={'blogpost': instance.key}) 


class CommentResource(ModelResource):
    """
    A Comment is associated with a given Blog Post and has a *username* and *comment*, and optionally a *rating*. 
    """
    model = Comment
    fields = ('username', 'comment', 'created', 'rating', 'url', 'blogpost')
    ordering = ('-created',)


urlpatterns = patterns('',
    url(r'^$', ListOrCreateModelView.as_view(resource=BlogPostResource), name='blog-posts-root'),
    url(r'^(?P[^/]+)/$', InstanceModelView.as_view(resource=BlogPostResource)),
    url(r'^(?P[^/]+)/comments/$', ListOrCreateModelView.as_view(resource=CommentResource), name='comments'),
    url(r'^(?P[^/]+)/comments/(?P[^/]+)/$', InstanceModelView.as_view(resource=CommentResource)),
)
github encode / django-rest-framework / examples / modelresourceexample / urls.py View on Github external
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from modelresourceexample.resources import MyModelResource

urlpatterns = patterns('',
    url(r'^$',          ListOrCreateModelView.as_view(resource=MyModelResource), name='model-resource-root'),
    url(r'^(?P[0-9]+)/$', InstanceModelView.as_view(resource=MyModelResource)),
)
github dploi / dploi-server / dploi_server / api_urls.py View on Github external
#-*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from dploi_server.resources import ApplicationConfigResource
from .resources import ApplicationResource

urlpatterns = patterns('',
    url(r'^applications/$',          ListOrCreateModelView.as_view(resource=ApplicationResource), name='application-resource-root'),
    url(r'^applications/(?P[a-z0-9_]+)/$', InstanceModelView.as_view(resource=ApplicationResource)),
    url(r'^applications/(?P[a-z0-9_]+)/config/$', InstanceModelView.as_view(resource=ApplicationConfigResource)),
)
github ptone / django-live / django_project / colorpicks / api_urls.py View on Github external
from django.conf.urls.defaults import patterns, url

from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from .resources import ColorResource

urlpatterns = patterns('',
    url(r'^colors/$',
        ListOrCreateModelView.as_view(resource=ColorResource),
        name='todo-resources'),
    url(r'^colors/(?P[0-9]+)$',
        InstanceModelView.as_view(resource=ColorResource)),
)
github paulmillr / chieftain / api1 / urls.py View on Github external
(r"^post/(?P\d+)$",
        PostInstanceView.as_view(resource=PostResource)),
    (r"^post/(?P\w+)/(?P\d+)$",
        PostInstanceView.as_view(resource=PostResource)),

    (r"^section/$",
        ListOrCreateModelView.as_view(resource=SectionResource)),
    (r"^section/(?P\d+)$",
        InstanceModelView.as_view(resource=SectionResource)),
    (r"^section/(?P\w+)",
        InstanceModelView.as_view(resource=SectionResource)),

    (r"^sectiongroup/",
        ListOrCreateModelView.as_view(resource=SectionGroupResource)),
    (r"^sectiongroup/(?P\d+)",
        InstanceModelView.as_view(resource=SectionGroupResource)),

    (r"^file/$",
        ListOrCreateModelView.as_view(resource=FileResource)),
    (r"^file/(?P\d+)$",
        FileInstanceView.as_view(resource=FileResource)),
    (r"^file/random_image/(?P\d{1,2})",
        RandomImageView.as_view(resource=FileResource)),

    (r"^filetype/(?P\d+)$",
        InstanceModelView.as_view(resource=FileTypeResource)),
    (r"^filetype/(?P[\w\d]+)$",
        InstanceModelView.as_view(resource=FileTypeResource)),

    (r"^filetypegroup/$",
        ListOrCreateModelView.as_view(resource=FileTypeGroupResource)),
    (r"^filetypegroup/(?P\d+)$",
github paulmillr / chieftain / api1 / urls.py View on Github external
(r"^post/(?P\w+)/$",
        PostListOrCreateView.as_view(resource=PostResource)),
    (r"^post/(?P\w+)/first/$",
        PostListOrCreateView.as_view(resource=PostResource),
        {"is_op_post": True}),
    (r"^post/(?P\d+)$",
        PostInstanceView.as_view(resource=PostResource)),
    (r"^post/(?P\w+)/(?P\d+)$",
        PostInstanceView.as_view(resource=PostResource)),

    (r"^section/$",
        ListOrCreateModelView.as_view(resource=SectionResource)),
    (r"^section/(?P\d+)$",
        InstanceModelView.as_view(resource=SectionResource)),
    (r"^section/(?P\w+)",
        InstanceModelView.as_view(resource=SectionResource)),

    (r"^sectiongroup/",
        ListOrCreateModelView.as_view(resource=SectionGroupResource)),
    (r"^sectiongroup/(?P\d+)",
        InstanceModelView.as_view(resource=SectionGroupResource)),

    (r"^file/$",
        ListOrCreateModelView.as_view(resource=FileResource)),
    (r"^file/(?P\d+)$",
        FileInstanceView.as_view(resource=FileResource)),
    (r"^file/random_image/(?P\d{1,2})",
        RandomImageView.as_view(resource=FileResource)),

    (r"^filetype/(?P\d+)$",
        InstanceModelView.as_view(resource=FileTypeResource)),
    (r"^filetype/(?P[\w\d]+)$",
github dploi / dploi-server / dploi_server / api_urls.py View on Github external
#-*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from dploi_server.resources import ApplicationConfigResource
from .resources import ApplicationResource

urlpatterns = patterns('',
    url(r'^applications/$',          ListOrCreateModelView.as_view(resource=ApplicationResource), name='application-resource-root'),
    url(r'^applications/(?P[a-z0-9_]+)/$', InstanceModelView.as_view(resource=ApplicationResource)),
    url(r'^applications/(?P[a-z0-9_]+)/config/$', InstanceModelView.as_view(resource=ApplicationConfigResource)),
)