本文整理汇总了Python中djangorestframework.views.InstanceModelView.as_view方法的典型用法代码示例。如果您正苦于以下问题:Python InstanceModelView.as_view方法的具体用法?Python InstanceModelView.as_view怎么用?Python InstanceModelView.as_view使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类djangorestframework.views.InstanceModelView
的用法示例。
在下文中一共展示了InstanceModelView.as_view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_narcissus_urls
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
def add_narcissus_urls(urls):
urls += patterns('',
url(r'^dashboard/', include('narcissus.dashboard.urls')),
url(r'^api/user/(?P<pk>[^/]+)/$', InstanceModelView.as_view(
resource=UserResource, permissions=(SameUserOrReadOnly,),
), name='narcissus-user-detail'),
)
for name, posttype in posttypes.items():
urls += patterns('',
url(r'^api/%s/$' % name,
ListOrCreateModelView.as_view(
resource=posttype.resource,
permissions=(permissions.IsUserOrIsAnonReadOnly,),
),
name='narcissus-api-%s' % name),
url(r'^api/%s/(?P<pk>[^/]+)/$' % name,
InstanceModelView.as_view(
resource=posttype.resource,
permissions=(SameUserOrReadOnly,),
),
name='narcissus-api-%s-detail' % name),
)
return urls
示例2: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
#-*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from .resources import ApplicationResource
urlpatterns = patterns('',
url(r'^applications/$', ListOrCreateModelView.as_view(resource=ApplicationResource), name='application-resource-root'),
url(r'^applications/(?P<name>[a-z0-9_]+)/$', InstanceModelView.as_view(resource=ApplicationResource)),
)
示例3: BackupTaskResource
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from scheduler.views import Todo
from views import *
class BackupTaskResource(ModelResource):
model = BackupTask
class BackupsTodo(Todo):
queryset = BackupTask.objects.all()
class TSMBackupsTodo(BackupsTodo):
queryset = TSMBackupTask.objects.all()
class R1BackupsTodo(BackupsTodo):
queryset = R1BackupTask.objects.all()
urlpatterns = patterns('',
url(r'^$', ListOrCreateModelView.as_view(resource=BackupTaskResource)),
url(r'^tsm/hosts/$', TSMHostsView.as_view(), name='tsm-hosts'),
url(r'^r1/todo/$', R1BackupsTodo.as_view(), name='r1-backups-todo'),
url(r'^todo/$', BackupsTodo.as_view(), name='backups-todo'),
url(r'^backupfilechecker/$', BackupFileCheckerView.as_view(), name='backup-file-checker'),
url(r'^filesToCompress$', FilesToCompressView.as_view(), name='backup-files-to-compress'),
url(r'^filesToDelete$', FilesToDeleteView.as_view(), name='backup-files-to-delete'),
url(r'^addBackupFile$', add_backup_file, name="addBackupFile"),
url(r'^BackupFileInfo$', GetBackupFileInfo.as_view(), name="BackupFileInfo"),
url(r'^addWindowsBackupFile$', add_backup_file, { 'windows':True }, name="addWindowsBackupFile"),
url(r'^registerFileFromChecker$', register_file_from_checker, name="register_file_from_checker"),
url(r'^addCompressedBackupFile$', add_compressed_backup_file, name="addCompressedBackupFile"),
url(r'^(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=BackupTaskResource)),
)
示例4: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls.defaults import patterns, include, url
from djangorestframework.views import InstanceModelView, ListOrCreateModelView
from resources import CardResource
urlpatterns = patterns('',
url(r'^cards/?$', ListOrCreateModelView.as_view(resource=CardResource), name='card_list_or_create_model_view'),
url(r'^cards/(?P<id>\d+)/?$', InstanceModelView.as_view(resource=CardResource), name='card_instance_model_view'),
)
示例5: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
try:
from django.conf.urls import patterns, url
except ImportError:
# Django < 1.4
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from blogpost.resources import BlogPostResource, CommentResource
urlpatterns = patterns('',
url(r'^$', ListOrCreateModelView.as_view(resource=BlogPostResource), name='blog-posts-root'),
url(r'^(?P<key>[^/]+)/$', InstanceModelView.as_view(resource=BlogPostResource), name='blog-post'),
url(r'^(?P<blogpost>[^/]+)/comments/$', ListOrCreateModelView.as_view(resource=CommentResource), name='comments'),
url(r'^(?P<blogpost>[^/]+)/comments/(?P<id>[^/]+)/$', InstanceModelView.as_view(resource=CommentResource)),
)
示例6: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
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<pk>[0-9]+)/$', InstanceModelView.as_view(resource=MyModelResource)),
)
示例7: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls import patterns, include, url
from djangorestframework.permissions import IsUserOrIsAnonReadOnly
from djangorestframework.views import InstanceModelView, ListOrCreateModelView, \
ListModelView
from events.resources import ConventionResource, GameResource, PublisherResource, \
DemandResource, UserResource
from events.views import ApiRoot, EventRoot, EventModelView, EventJoinView, \
EventLeaveView, DemandRoot, DemandModelView, UserModelView
urlpatterns = patterns('events',
url(r'^$', ApiRoot.as_view()),
url(r'^publishers/$', ListOrCreateModelView.as_view(
resource=PublisherResource, permissions=(IsUserOrIsAnonReadOnly, )),
name='publisher-list'),
url(r'^publishers/(?P<pk>[^/]+)/$', InstanceModelView.as_view(
resource=PublisherResource, permissions=(IsUserOrIsAnonReadOnly, )),
name='publisher-instance'),
url(r'^games/$', ListOrCreateModelView.as_view(resource=GameResource,
permissions=(IsUserOrIsAnonReadOnly, )), name='game-list'),
url(r'^games/(?P<pk>[^/]+)/$', InstanceModelView.as_view(
resource=GameResource, permissions=(IsUserOrIsAnonReadOnly, )),
name='game-instance'),
url(r'^conventions/$', ListOrCreateModelView.as_view(
resource=ConventionResource, permissions=(IsUserOrIsAnonReadOnly, )),
name='convention-list'),
url(r'^conventions/(?P<pk>[^/]+)$', InstanceModelView.as_view(
resource=ConventionResource, permissions=(IsUserOrIsAnonReadOnly, )),
name='convention-instance'),
示例8: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from apps.todos.resources import TodoResource
my_model_list = ListOrCreateModelView.as_view(resource=TodoResource)
my_model_instance = InstanceModelView.as_view(resource=TodoResource)
urlpatterns = patterns('',
url(r'^todos/$', my_model_list, name='todos_api_root'),
url(r'^todos/(?P<id>[0-9]+)$', my_model_instance, name='todos_api_instance'),
)
示例9: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls.defaults import patterns, url,include
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from resources import MyModelResource
from django.contrib import admin
from views import getProgress
from views import getProgressBarData
from views import getProgressLog
from django.conf import settings
admin.autodiscover()
my_model_list = ListOrCreateModelView.as_view(resource=MyModelResource)
my_model_instance = InstanceModelView.as_view(resource=MyModelResource)
urlpatterns = patterns('',
url(r'^restframework', include('djangorestframework.urls', namespace='djangorestframework')),
url(r'^$', my_model_list, name='model-resource-root'),
url(r'^(?P<id>[0-9]+)/$', my_model_instance, name='model-resource-instance'),
url(r'^admin/', include(admin.site.urls)),
url(r'^getProgress/',getProgress),
url(r'^getProgressBarData$',getProgressBarData),
url(r'^getProgressLog/',getProgressLog),
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT,})
)
示例10: UserProfileResource
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls import patterns, url
from djangorestframework.resources import ModelResource
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from cuba.models.accounts import UserProfile
from cuba.utils import const
from cuba.views.accounts import UserDetailView
class UserProfileResource(ModelResource):
model = UserProfile
urlpatterns = patterns('',
url(const.MATCH_SLUG, UserDetailView.as_view(), name='user_detail'),
url(r'api/^$', ListOrCreateModelView.as_view(resource=UserProfileResource)),
url(r'^%s/$' % const.MATCH_PK, InstanceModelView.as_view(resource=UserProfileResource)),
)
示例11: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls.defaults import patterns, include, url
from resources import *
from views import *
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
urlpatterns = patterns('',
# customed view/handler
# (r'poll/(?P<pid>[^/]+)/choice/(?P<cid>[^/]+)', RESTforPollAndChoice.as_view(resource=ChoiceItemResource)),
# (r'poll/', RESTforPoll.as_view(resource=PollItemResource)),
# built-in view/handler
(r'cycle/(?P<id>[^/]+)', InstanceModelView.as_view(resource=CycleItemResource)),
(r'cycle/', ListOrCreateModelView.as_view(resource=CycleItemResource)),
(r'package/(?P<id>[^/]+)', InstanceModelView.as_view(resource=PackageItemResource)),
(r'package/', ListOrCreateModelView.as_view(resource=PackageItemResource)),
(r'card/(?P<id>[^/]+)', InstanceModelView.as_view(resource=CardItemResource)),
(r'card/', ListOrCreateModelView.as_view(resource=CardItemResource)),
)
示例12: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from .resources import TodoResource
urlpatterns = patterns('',
url(r'^todos/$',
ListOrCreateModelView.as_view(resource=TodoResource),
name='todo-resources'),
url(r'^todos/(?P<pk>[0-9]+)/$',
InstanceModelView.as_view(resource=TodoResource),
name='todo-resources'),
)
示例13: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
# urls.py
# =======
from graph.api import *
from django.conf.urls.defaults import patterns, url
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
urlpatterns = patterns('',
url(r'^api/person/$', ListOrCreateModelView.as_view(resource=PersonResource)),
url(r'^api/person/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=PersonResource)),
url(r'^api/evaluation/$', ListOrCreateModelView.as_view(resource=EvaluationResource)),
url(r'^api/evaluation/(?P<pk>[^/]+)/$', InstanceModelView.as_view(resource=EvaluationResource)),
)
示例14: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls import patterns, include, url
from django.contrib import admin
from wic.views import *
from djangorestframework.views import ListModelView, InstanceModelView
from wic.resources import *
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^news/(?P<slug>[^\.]+)', 'wic.views.view_article' , name='view_article'),
url(r'^live/$', 'wic.views.gigs_index' ),
url(r'^live/previous/$', 'wic.views.gigs_old' ),
url(r'^gigs/(?P<slug>[^\.]+)', 'wic.views.view_gig' , name='view_gig'),
url(r'^media/photos/$', 'wic.views.media_photos' ),
url(r'^media/discography/$', 'wic.views.media_discography' ),
url(r'^media/videos/$', 'wic.views.media_videos' ),
url(r'^band/$', 'wic.views.band_index' ),
url(r'^contact/$', 'wic.views.contact' ),
url(r'^thanks/$', 'django.views.generic.simple.direct_to_template', {'template': 'contact-thanks.html'}),
url(r'^$', 'wic.views.main_index' ),
url(r'^api/devices/$', AuthenticatedListOrCreateModelView.as_view(resource=DeviceTokensResource)),
url(r'^api/live/$', ListModelView.as_view(resource=GigsResource)),
url(r'^api/photos/$', ListModelView.as_view(resource=PhotosResource)),
url(r'^api/discography/$', ListModelView.as_view(resource=DiscographyResource)),
url(r'^api/members/$', ListModelView.as_view(resource=MembersResource)),
url(r'^api/news/$', ListModelView.as_view(resource=NewsResource)),
url(r'^api/news/(?P<slug>[^\.]+)/$', InstanceModelView.as_view(resource=NewsResource)),
url(r'^api/albums/$', ListModelView.as_view(resource=AlbumsResource)),
)
示例15: patterns
# 需要导入模块: from djangorestframework.views import InstanceModelView [as 别名]
# 或者: from djangorestframework.views.InstanceModelView import as_view [as 别名]
from django.conf.urls import patterns, include, url
from djangorestframework.views import InstanceModelView, ListOrCreateModelView
from basicapi import resources as rs
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^horses/?$', ListOrCreateModelView.as_view(resource=rs.HorseResource), name='horse_instance'),
url(r'^horses/(?P<id>\d+)/?$', InstanceModelView.as_view(resource=rs.HorseResource), name='horse_instance'),
url(r'^restframework', include('djangorestframework.urls', namespace='djangorestframework'))
# url(r'^simpleapi/', include('simpleapi.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),
)