Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)),
)
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)),
)
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)),
)
#-*- 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)),
)
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)),
)
(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+)$",
(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]+)$",
#-*- 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)),
)