当前位置: 首页>>代码示例>>Python>>正文


Python generic.DeleteView类代码示例

本文整理汇总了Python中django.views.generic.DeleteView的典型用法代码示例。如果您正苦于以下问题:Python DeleteView类的具体用法?Python DeleteView怎么用?Python DeleteView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DeleteView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

 def post(self, *args, **kwargs):
     """ safe guard for POST to make sure only owner can delete his own poll """
     question = get_object_or_404(Question,pk=kwargs['pk'])
     
     if question.created_by == self.request.user :
         return DeleteView.post(self, *args, **kwargs)
     else :
         return HttpResponseForbidden('you are not allowed to do this')
开发者ID:drayanaindra,项目名称:polling,代码行数:8,代码来源:views.py

示例2: get

    def get(self, request, *args, **kwargs):
        """ safe guard for GET to make sure anybody beside the owner, can not delete poll """
#         questions = Question.objects.filter(pk=kwargs['pk'])
        question = get_object_or_404(Question,pk=kwargs['pk'])
        if question.created_by == request.user :
            return DeleteView.get(self, request, *args, **kwargs)
        else :
            return HttpResponseForbidden('you are not allowed to do this')
开发者ID:drayanaindra,项目名称:polling,代码行数:8,代码来源:views.py

示例3: render_to_response

 def render_to_response(self, context, **response_kwargs):
     if self.request.REQUEST.get('next', False):
         context['next'] = self.request.REQUEST.get('next')
     elif self.success_view:
         context['next'] = reverse(self.success_view)
     elif self.request.META.get('HTTP_REFERER', False):
         # Note that if this is the object being deleted it won't work, but what other option do we have...
         context['next'] = self.request.META.get('HTTP_REFERER')
     return DeleteView.render_to_response(self, context, **response_kwargs)
开发者ID:NavyaEV,项目名称:instagram,代码行数:9,代码来源:views.py

示例4: route

def route(request, view_kwargs={}, pk=None):
    """
    Route to the correct view based on Method or the existance of
    pk.
    """

    if request.method == "DELETE":
        return DeleteView.as_view(**view_kwargs)(request=request, pk=pk)
    else:
        if pk:
            return UpdateView.as_view(**view_kwargs)(request=request, pk=pk)
        else:
            return CreateView.as_view(**view_kwargs)(request=request)
开发者ID:graingert,项目名称:maluroam,代码行数:13,代码来源:views.py

示例5: get_context_data

 def get_context_data(self, **kwargs):
     context = DeleteView.get_context_data(self, **kwargs)
     if self.breadcrumbs:
         context['breadcrumbs'] = []
         for breadcrumb in self.breadcrumbs:
             if 'title' not in breadcrumb:
                 breadcrumb['title'] = self.object
             context['breadcrumbs'].append({
                 'href': reverse(breadcrumb['viewname']),
                 'title': breadcrumb['title']
             })
         context['breadcrumbs'].append({
             'href': self.object.get_absolute_url(),
             'title': self.object
         })
         context['breadcrumbs'].append({
             'href': self.request.path,
             'title': 'Update'
         })
     return context
开发者ID:NavyaEV,项目名称:instagram,代码行数:20,代码来源:views.py

示例6: delete_event

def delete_event(request, event_id, next=None, login_required=True):
    """
    After the event is deleted there are three options for redirect, tried in
    this order:

    # Try to find a 'next' GET variable
    # If the key word argument redirect is set
    # Lastly redirect to the event detail of the recently create event
    """
    event = get_object_or_404(Event, id=event_id)
    next = next or reverse('day_calendar', args=[event.calendar.slug])
    next = get_next_url(request, next)
    return DeleteView.as_view(request,
                         model = Event,
                         object_id = event_id,
                         post_delete_redirect = next,
                         template_name = "schedule/delete_event.html",
                         extra_context = dict(next=next),
                         login_required = login_required
                        )
开发者ID:saviosabino,项目名称:django-schedule,代码行数:20,代码来源:views.py

示例7: get_object

 def get_object(self,*args,**kwargs):
     obj=DeleteView.get_object(self,*args,**kwargs)
     self.success_url=obj.content_object.get_absolute_url()
     if self.anchor:
         self.success_url+="#"+self.anchor
     return obj
开发者ID:chiara-paci,项目名称:santaclara-base,代码行数:6,代码来源:views.py

示例8: reverse

			property_value = False,
			redirect = lambda obj, kwargs: reverse("exhibitor_participants", kwargs = { "pk" : obj.project_id }) )),
		name="exhibitor_participants_revoke_admin"),
	url(r'^list\+planning/?',
		user_is_staff(ListView.as_view(
			queryset = Exhibitor.objects.select_related(),
			template_name = "exhibitor/list+planning.html")),
			name="exhibitor_list_planning"),
	url(r'^list/?',
		user_is_staff(ListView.as_view(
			queryset = Exhibitor.objects.select_related(),
			template_name = "exhibitor/list.html")),
			name="exhibitor_list"),
	url(r'^del/(?P<pk>[0-9]+)$',
		user_is_staff(DeleteView.as_view(
			model = Exhibitor,
			template_name= "exhibitor/del.html",
			success_url="/exhibitors/list")),
			name="exhibitor_del"),
	url(r'^export/adminmail',
		user_is_staff(EmailOutputView.as_view(
			queryset = User.objects.filter(Q(exhibitorparticipants__isAdmin=True,exhibitorparticipants__project__accepted=True) | Q(exhibitors__accepted=True)).distinct(),
			template_name = "mail.html")),
			name="exhibitor_export_adminmail"),
	url(r'export/allmail',
		user_is_staff(EmailOutputView.as_view(
			queryset = User.objects.filter(Q(exhibitorparticipants__project__accepted=True) | Q(exhibitors__accepted=True)).distinct(),
			template_name = "mail.html")),
			name="exhibitor_export_allmail"),
	url(r'^export/xml',
		user_is_staff(XMLListView.as_view(
			queryset = Exhibitor.objects.select_related().filter(accepted=True),
开发者ID:InsanePrawn,项目名称:SaBoT,代码行数:32,代码来源:urls.py

示例9: url

                    form_class=UserCreationForm,
                    success_url='/'), name='rejestruj'),
    url(r'^loguj/', 'django.contrib.auth.views.login',
                    {'template_name': 'czat/loguj.html'},
                    name='loguj'),
    url(r'^wyloguj/', 'django.contrib.auth.views.logout',
                    {'next_page': reverse_lazy('index')},
                    name='wyloguj'),
    url(r'^wiadomosci/', login_required(
                    ListView.as_view(
                        model=Wiadomosc,
                        context_object_name='wiadomosci',
                        paginate_by=10),
                    login_url='/loguj'),
                    name='wiadomosci'),
    url(r'^wiadomosc/$', login_required(
                    views.UtworzWiadomosc.as_view(),
                    login_url='/loguj'), name='wiadomosc'),
    url(r'^aktualizuj/(?P<pk>\d+)/', login_required(
                    views.AktualizujWiadomosc.as_view(),
                    login_url='/loguj'), name='aktualizuj'),
    url(r'^usun/(?P<pk>\d+)/', login_required(
                    DeleteView.as_view(
                    model=Wiadomosc,
                    template_name='czat/wiadomosc_usun.html',
                    success_url='/wiadomosci'),
                    login_url='/loguj'), name='usun'),

    url(r'^admin/', include(admin.site.urls)),
)
开发者ID:astefaniuk,项目名称:linetc,代码行数:30,代码来源:urls_z9.py

示例10:

from django.core.urlresolvers import reverse_lazy
from django.views.generic import DetailView, CreateView, UpdateView, DeleteView
from blog.models import Post
from blog.forms import PostModelForm


# 기본 template_name : 모델명_detail.html
post_detail = DetailView.as_view(model=Post)

# 기본 template_name : 모델명_form.html
post_new = CreateView.as_view(model=Post, form_class=PostModelForm)

# 기본 template_name : 모델명_form.html
post_edit = UpdateView.as_view(model=Post, form_class=PostModelForm)

# 기본 template_name : 모델명_confirm_delete.html
post_delete = DeleteView.as_view(model=Post, success_url=reverse_lazy('blog:index'))
开发者ID:allieus,项目名称:askdjango-4th,代码行数:17,代码来源:views_cbv.py

示例11: url

        name="detail_video"
    ),
    url(
        r'^test/youtubevideo/detail/(?P<pk>\d+)/$',
        DetailMedia.as_view(
            model=YoutubeVideo,
            template_name='test/youtube/detail.html'
        ),
        name="detail_youtubevideo"
    ),

    # delete
    url(
        r'^test/video/delete/(?P<pk>\d+)/$',
        DeleteView.as_view(
            model=Video,
            success_url=reverse_lazy('list_video')
        ),
        name="delete_video"
    ),
    url(
        r'^test/youtubevideo/delete/(?P<pk>\d+)/$',
        DeleteView.as_view(
            model=YoutubeVideo,
            success_url=reverse_lazy('list_youtubevideo')
        ),
        name="delete_youtubevideo"
    ),

###########################################################
    url(
        r'^test/youtubevideo/multiple/create/$',
开发者ID:aaboffill,项目名称:django-allmedia,代码行数:32,代码来源:urls.py

示例12: url

from django.conf.urls import url
from django.views.generic import DeleteView
from views import *

urlpatterns = [
    url(r"^overview/$", IndexView.as_view(), name="server_overview"),
    url(r"^monitor/$", MonitorView.as_view(), name="server_monitor"),
    #     url(r'^monitor/(?P<pk>\d+)/$', MonitorDetailView.as_view() ,name='server_detail'),
    url(r"^monitor/detail/$", MonitorDetailView.as_view(), name="server_detail"),
    url(r"^manager/$", ManagerView.as_view(), name="server_manager"),
    url(r"^manager/add/$", ServerAddView.as_view(), name="server_manager_add"),
    url(r"^manager/(?P<pk>\d+)/edit/$", ServerEditView.as_view(), name="server_manager_edit"),
    url(r"^manager/(?P<pk>\d+)/delete/$", ServerDeleteView.as_view(), name="server_manager_delete"),
    url(r"^collector/$", CollectorView.as_view(), name="server_collector"),
    url(r"^collector/(?P<pk>\d+)/$", CollectorView.as_view(), name="server_collector_detail"),
    url(r"^collector/add/$", CollertorAddView.as_view(), name="server_collector_add"),
    url(r"^collector/(?P<pk>\d+)/edit/$", CollertorEditView.as_view(), name="server_collector_edit"),
    url(
        r"^collector/(?P<pk>\d+)/delete/$",
        DeleteView.as_view(model=Collector, success_url=reverse_lazy("newtouch:server:server_collector")),
        name="server_collector_delete",
    ),
    url(r"^rules/$", IndexView.as_view(), name="server_rules"),
    url(r"^chart/$", ChartData.as_view(), name="chart_data"),
    url(r"^host/$", ChartHost.as_view(), name="host_ip"),
]
开发者ID:zouyapeng,项目名称:NewtouchMonitor,代码行数:26,代码来源:urls.py

示例13: url

	url(r'^(?P<pk>[0-9]+)$',
		user_is_staff(UpdateView.as_view(
			model = SponsorPackage,
			form_class = SponsorPackageForm,
			template_name = "sponsor/package/update.html",
			success_url = "list")),
		name = "sponsorpackage_update"),
	url(r'^list/?',
		user_is_staff(MultipleListView.as_view(
			template_name = "sponsor/package/list.html",
			template_params = {
				"object_list" : lambda req, kwargs : SponsorPackage.objects.filter(year=getActiveYear(req)),
				"importerForm" : lambda req, kwargs : PackagesImporterForm(),
				})),
			name="sponsorpackage_list"),
	url(r'^del/(?P<pk>[0-9]+)$',
		user_is_staff(DeleteView.as_view(
			model = SponsorPackage,
			template_name= "sponsor/package/del.html",
			success_url="../list")),
			name="sponsorpackage_del"),
	url(r'^export/xml',
		user_is_staff(YSXMLListView.as_view(
			queryset = SponsorPackage.objects.all(),
			template_name = "sponsor/package/xmlexport.html")),
			name="sponsorpackage_export_xml"),
	url(r"^import$",
		user_is_staff(PackagesImporterView.as_view()),
			name="sponsorpackage_import"),
]
开发者ID:froscon,项目名称:SaBoT,代码行数:30,代码来源:urls_sponsorpackages.py

示例14: get_success_url

 def get_success_url(self):
     if self.request.POST.has_key('next'):
         return self.request.POST.get('next')
     if self.success_view:
         return reverse(self.success_view)
     return DeleteView.get_success_url(self) 
开发者ID:NavyaEV,项目名称:instagram,代码行数:6,代码来源:views.py

示例15: home

from django.shortcuts import render
from django.core.urlresolvers import reverse_lazy as r
from django.views.generic import CreateView, ListView, DetailView
from django.views.generic import UpdateView, DeleteView
from .mixins import NameSearchMixin
from .models import Person
from .forms import PersonForm


def home(request):
    return render(request, 'index.html')


class PersonList(NameSearchMixin, ListView):
    model = Person
    paginate_by = 5


person_detail = DetailView.as_view(model=Person)

person_create = CreateView.as_view(model=Person, form_class=PersonForm)

person_update = UpdateView.as_view(model=Person, form_class=PersonForm)

person_delete = DeleteView.as_view(model=Person, success_url=r('core:person_list'))
开发者ID:julianobernardesc,项目名称:proposal,代码行数:25,代码来源:views.py


注:本文中的django.views.generic.DeleteView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。