當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。