本文整理汇总了Python中django.views.generic.DeleteView.as_view方法的典型用法代码示例。如果您正苦于以下问题:Python DeleteView.as_view方法的具体用法?Python DeleteView.as_view怎么用?Python DeleteView.as_view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.views.generic.DeleteView
的用法示例。
在下文中一共展示了DeleteView.as_view方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: route
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
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)
示例2: delete_event
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
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
)
示例3: patterns
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
from django.conf.urls import patterns, url
from django.views.generic import DetailView, ListView, DeleteView
from django.core.urlresolvers import reverse_lazy
from ..tutor.auth import tutorbest_required
from .feed import NewsFeed
from .models import NewsPost
from .views import *
urlpatterns = patterns('',
url(r'^(?:(?P<year>\d+)/(?:(?P<month>\d+)/(?:(?P<day>\d+)/(?:(?P<pk>\d+)/)?)?)?)?$',
NewsView.as_view(), name='news'),
url(r'^add/$', NewsCreateView.as_view(), name='news_add'),
url(r'^edit/(?P<pk>\d+)/$', NewsUpdateView.as_view(), name='news_edit'),
url(r'^delete/(?P<pk>\d+)/$',
tutorbest_required(DeleteView.as_view(model=NewsPost, success_url=reverse_lazy('news'))),
name='news_delete'),
url(r'^feed/$', NewsFeed(), name='news_feed'),
)
示例4: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
), name="golfstats-courses-arenas-create"),
url(r'^arenas/(?P<pk>\d+)/$', ArenaDetailView.as_view(
model=Arena,
context_object_name="arena",
), name="golfstats-courses-arenas-detail"),
url(r'^arenas/(?P<pk>\d+)/edit/', UpdateView.as_view(
model=Arena,
context_object_name="arena",
success_url=reverse_lazy('golfstats-courses-arenas'),
), name="golfstats-courses-arenas-edit"),
url(r'^arenas/(?P<pk>\d+)/delete/$', DeleteView.as_view(
model=Arena,
context_object_name="arena",
success_url=reverse_lazy('golfstats-courses-arenas'),
), name="golfstats-courses-arenas-delete"),
# Tees
url(r'^tees/$', ListView.as_view(
model=Tee,
context_object_name="tees",
), name="golfstats-courses-tees"),
url(r'^tees/create/$', CreateView.as_view(
model=Tee,
success_url=reverse_lazy('golfstats-courses-tees'),
), name="golfstats-courses-tee-create"),
url(r'^tees/(?P<pk>\d+)/$', DetailView.as_view(
示例5: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
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"),
]
示例6: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
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"),
]
示例7: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
CreateView.as_view(
model = Entry,
success_url = '/entries/',
template_name = 'entries/entry_form.html',
form_class = HTML5Form)),
url(r'^detail/(?P<pk>\d+)/$',
DetailView.as_view(
model = Entry,
template_name = 'entries/entry_detail.html'),
name = "entry_detail"),
url(r'^update/(?P<pk>\d+)/$',
UpdateView.as_view(
model = Entry,
template_name = 'entries/entry_form.html',
form_class = HTML5Form)),
url(r'^delete/(?P<pk>\d+)/$',
DeleteView.as_view(
model = Entry,
success_url = '/entries/',
template_name = 'entries/entry_confirm_delete.html')),
)
urlpatterns += patterns('',
(r'^login/$', 'django.contrib.auth.views.login',
{'template_name':'entries/registration/login.html'}),
(r'^logout/$', 'django.contrib.auth.views.logout',
{'template_name':'entries/registration/logout.html'}),
)
urlpatterns += staticfiles_urlpatterns()
示例8: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
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)),
)
示例9: patterns
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
from django.contrib.auth.decorators import login_required
from core.models import News, Category, Event, Product
from core.views import NewsCreate, NewsUpdate, EventCreate, ProductCreate, ClassificationList
from django.conf.urls.static import static
from django.conf import settings
urlpatterns = patterns('',
url(r'^usuarios/$', login_required(ListView.as_view(template_name="users.html", model=User,
paginate_by=20)), name='users'),
url(r'^agregar-usuario/$', login_required(CreateView.as_view(
model=User, form_class=UserForm, template_name="user_form.html", success_url='/usuarios/')),
name='create_user'),
url(r'^modificar-usuario/(?P<pk>\d+)/$', login_required(UpdateView.as_view(
model=User, form_class=UserUpdateForm, template_name="user_form.html", success_url='/usuarios/')),
name='update_user'),
url(r'^eliminar-usuario/(?P<pk>\d+)/$', login_required(DeleteView.as_view(
model=User, success_url='/usuarios/')), name='delete_user'),
url(r'^iniciar-sesion/$', auth_views.login, {'template_name': 'user/login_logout_register/sign-in.html'},
name='auth_login'),
url(r'^cerrar-sesion/$', auth_views.logout, {'next_page': '/iniciar-sesion/'},
name='auth_logout'),
#Noticias
url(r'^noticias/$', login_required(ListView.as_view(template_name="news.html", model=News,
paginate_by=20)), name='news'),
url(r'^agregar-noticia/$', login_required(NewsCreate.as_view()), name='create_news'),
url(r'^modificar-noticia/(?P<pk>\d+)/$', login_required(NewsUpdate.as_view()), name='update_news'),
url(r'^eliminar-noticia/(?P<pk>\d+)/$', login_required(DeleteView.as_view(
model=News, success_url='/noticias/')), name='delete_news'),
#Categorias
url(r'^categorias/$', login_required(ListView.as_view(template_name="categories.html", model=Category,
paginate_by=20)), name='categories'),
url(r'^agregar-categoria/$', login_required(CreateView.as_view(
示例10: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
#web 2.0
# Crear Escola, equip, reglament, instalacions
url(r'^escola/Crear/$',EscolaCreate.as_view(),name='escola_create'),
url(r'^equip/Crear/$',EquipCreate.as_view(),name='equip_create'),
url(r'^reglament/Crear/$',ReglamentCreate.as_view(),name='reglament_create'),
url(r'^instalacions/Crear/$',InstalacioCreate.as_view(),name='instalacio_create'),
# Edit
url(r'^escola/(?P<pk>\d+)/edit/$',login_required(UpdateView.as_view(model = Escole,template_name = 'form.html',form_class = EscolaForm)),name='escola_edit'),
url(r'^equip/(?P<pk>\d+)/edit/$',login_required(UpdateView.as_view(model = Equip,template_name = 'form.html',form_class = EquipForm)),name='equip_edit'),
url(r'^instalacions/(?P<pk>\d+)/edit/$',UpdateView.as_view(model = Instalacion,template_name = 'form.html',form_class = InstalacionForm),name='install_edit'),
url(r'^reglament/(?P<pk>\d+)/edit/$',UpdateView.as_view(model = Reglament,template_name = 'form.html',form_class = ReglamentForm),name='reglament_edit'),
#Delete
url(r'^escola/(?P<pk>\d+)/delete/$',DeleteView.as_view(model= Escole, template_name='delete.html',success_url = '/escola'),name='escola_delete'),
url(r'^equip/(?P<pk>\d+)/delete/$',DeleteView.as_view(model= Equip, template_name='delete.html',success_url = '/equip'),name='equip_delete'),
url(r'^instalacions/(?P<pk>\d+)/delete/$',DeleteView.as_view(model= Instalacion, template_name='delete.html',success_url = '/instalacions'),name='install_delete'),
url(r'^reglament/(?P<pk>\d+)/delete/$',DeleteView.as_view(model= Reglament, template_name='delete.html',success_url = '/reglament'),name='reglament_delete'),
#review
#url(r'^equip/(?P<idEquip>\d+)/reviews/create/$', review, name='review_create'),
url(r'^admin/', include(admin.site.urls)),
)
#RESTful API
urlpatterns += patterns('',
url(r'^api/escola/$', APIEscolaList.as_view(), name='escola-list'),
示例11: patterns
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
from apps.blog.models import Article
from apps.blog.views import ArticleListView, ArticleUnpublishedListView, ArticleDetailView
urlpatterns = patterns('',
url('^$', ArticleListView.as_view(), name="article_index"),
# 'unpublished' and 'new' are prefixed with '.' to prevent clash with a slug like 'new'.
url('^.unpublished/$',
login_required(ArticleUnpublishedListView.as_view()),
name="article_unpublished_index"),
url(r'^(?P<slug>[\w\d-]+)/$', ArticleDetailView.as_view(), name="article_view"),
url('^.new/$', # see above comment about '.' prefix.
login_required(CreateView.as_view(model=Article)),
name="article_new"),
url('^(?P<slug>[\w\d-]+)/edit/$',
login_required(UpdateView.as_view(model=Article, context_object_name="article")),
name="article_edit"),
url('^(?P<slug>[\w\d-]+)/delete/$',
login_required(DeleteView.as_view(model=Article,
context_object_name="article",
success_url="/blog/")), # @@@ Should be more DRY
name="article_delete"),
)
示例12: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
},
template_name = "parcel/admin/list.html")),
name = "parcel_list"),
url(r'^new',
user_is_staff(YSCreateView.as_view(
model = Parcel,
form_class = ParcelAdminForm,
template_name = "parcel/admin/update.html",
success_url = "parcel_list")),
name = "parcel_new"),
url(r'^(?P<pk>[0-9]+)$',
user_is_staff(UpdateView.as_view(
model = Parcel,
form_class = ParcelAdminForm,
template_name = "parcel/admin/update.html",
success_url = "list")),
name = "parcel_update"),
url(r'^del/(?P<pk>[0-9]+)$',
user_is_staff(DeleteView.as_view(
model = Parcel,
template_name= "parcel/admin/del.html",
success_url="../list")),
name = "parcel_del"),
url(r'query_owners',
user_is_staff(queryParcelOwners),
name = "parcel_query_owners"),
url(r'quick_store',
user_is_staff(packageQuickStore),
name = "parcel_quick_store"),
]
示例13: add_street
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
ordem_servico_new = CreateView.as_view(model=OrdemServico,
template_name='sistran/models/ordem_servico/'
'ordem_servico_form.html',
fields=['permissao', 'tipo_servico', 'pago'])
ordem_servico_edit = UpdateView.as_view(model=OrdemServico,
template_name='sistran/models/ordem_servico/'
'ordem_servico_form.html',
fields=['permissao', 'tipo_servico', 'pago'])
ordem_servico_remove = DeleteView.as_view(model=OrdemServico,
template_name='sistran/models/ordem_servico/'
'ordem_servico_confirm_delete.html',
success_url=reverse_lazy('ordem_servico_list'))
def add_street(request):
street = request.POST.get('new_street')
Logradouro.objects.create(logradouro=street.upper())
logradouros = AjaxLogradouroForm()
return HttpResponse(logradouros)
class ReportPDF(View):
permissao = get_object_or_404(PermissaoTemProprietario, pk=429)
endereco = Reside.objects.get(pessoa=permissao.proprietario.id.id.id.id)
示例14: url
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
url(
r'^(?P<slug>\S+)$',
DetailView.as_view(
model=Department,
template_name='eggplant/departments/department_detail.html',
context_object_name='department',
),
name='detail'
),
url(
r'^(?P<slug>\S+)/update$',
UpdateView.as_view(
model=Department,
template_name='eggplant/departments/department_form.html',
),
name='update'
),
url(
r'^(?P<slug>\S+)/delete$',
DeleteView.as_view(
model=Department,
template_name='eggplant/departments/department_delete.html',
context_object_name='department',
),
name='delete'
),
]
示例15:
# 需要导入模块: from django.views.generic import DeleteView [as 别名]
# 或者: from django.views.generic.DeleteView import as_view [as 别名]
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'))