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


Python UpdateView.as_view方法代码示例

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


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

示例1: __init__

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
    def __init__(self):
        self.create = login_required(CreateView.as_view(
            model=self.model,
            fields=('name',),
            success_url=reverse_lazy('laboratory:laboratory_list'),
            template_name=self.template_name_base + 'form.html'
        ))

        self.edit = login_required(UpdateView.as_view(
            model=self.model,
            fields=('name',),
            success_url=reverse_lazy('laboratory:laboratory_list'),
            template_name=self.template_name_base + 'form.html'
        ))

        self.delete = login_required(DeleteView.as_view(
            model=self.model,
            success_url=reverse_lazy('laboratory:laboratory_list'),
            template_name=self.template_name_base + 'delete.html'
        ))

        self.list = login_required(ListView.as_view(
            model=self.model,
            paginate_by=10,
            template_name=self.template_name_base + 'list.html'
        ))
开发者ID:solvo,项目名称:organilab,代码行数:28,代码来源:laboratory.py

示例2: user_register

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
def user_register(request, pk=None):
    view_kwargs = {
        'model': User, 
        'form_class': UserRegisterForm,
        'template_name': "people/register_form.html",
    }
    
    if pk is None:
        view_kwargs['success_url'] = "/people/profile/%(id)d/"
        return CreateView.as_view(**view_kwargs)(request)
    else:
        return UpdateView.as_view(**view_kwargs)(request, pk=pk)
开发者ID:rennerocha,项目名称:python-people,代码行数:14,代码来源:views.py

示例3: python_group_crud

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
def python_group_crud(request, pk=None):
    view_kwargs = {
        'model': PythonGroup, 
        'form_class': PythonGroupForm,
        'template_name': "people/pythongroup_form.html",
    }
    
    if pk is None:
        view_kwargs['success_url'] = "/pythongroup/list/"
        return PythonGroupCreateView.as_view(**view_kwargs)(request)
    else:
        return UpdateView.as_view(**view_kwargs)(request, pk=pk)
开发者ID:rennerocha,项目名称:python-people,代码行数:14,代码来源:views.py

示例4: route

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView 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)
开发者ID:graingert,项目名称:maluroam,代码行数:15,代码来源:views.py

示例5: user_register

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
def user_register(request, pk=None):
    view_kwargs = {
        'model': User,
        'form_class': UserRegisterForm,
        'template_name': "people/register_form.html",
        'message': u'Your account has been created ! Sig in to fullfill your profile.',
        'message_level': messages.INFO,
    }

    if pk is None:
        view_kwargs['success_url'] = "/login/"
        return CreateWMsgView.as_view(**view_kwargs)(request)
    else:
        return UpdateView.as_view(**view_kwargs)(request, pk=pk)
开发者ID:Maxwbh,项目名称:python-people,代码行数:16,代码来源:views.py

示例6: user_profile_upd

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
def user_profile_upd(request, id=None):
    view_kwargs = {
        'model': UserProfile, 
        'form_class': UserProfileForm,
        #'success_url': "/adm/userprofile/%(id)d/",
        'success_url': "/people/profile/"  + id +  "/",
        'template_name': "/people/userprofile_form.html",
    }
    
    user_profile, created = UserProfile.objects.get_or_create(user_id=id)
    
    if request.method == "POST":
        if user_profile.user.last_login.strftime("%d%m%Y%H%M%S") == user_profile.user.date_joined.strftime("%d%m%Y%H%M%S"):
            msg = u"Usuário registrado com sucesso!<br />Efetue o login no site."
            view_kwargs['success_url'] = settings.LOGIN_URL
        else:
            msg = u'Seus dados de perfil foram salvos.'
        messages.add_message(request, messages.INFO, msg)
    return UpdateView.as_view(**view_kwargs)(request, pk=user_profile.pk)  
开发者ID:rennerocha,项目名称:python-people,代码行数:21,代码来源:views.py

示例7: url

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
from sponsor.forms import SponsorContactForm, SponsorPackageForm, PackagesImporterForm
from sponsor.models import Sponsoring, SponsoringParticipants, SponsorContact, SponsorPackage
from sponsor.views import PackagesImporterView

urlpatterns = [
	url(r'^new',
		user_is_staff(YSCreateView.as_view(
			model = SponsorPackage,
			form_class = SponsorPackageForm,
			template_name = "sponsor/package/update.html",
			success_url = "./{id}")),
		name = "sponsorpackage_new"),
	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",
开发者ID:froscon,项目名称:SaBoT,代码行数:33,代码来源:urls_sponsorpackages.py

示例8: patterns

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
from __future__ import absolute_import

from django.conf.urls.defaults import patterns, url
from django.views.generic import ListView, UpdateView

from tests.universite.models import Universite
from tests.universite.forms import UniversiteForm

urlpatterns = patterns(
    '',
    url(r'^$', ListView.as_view(model=Universite), name='universite_list'),
    url(r'^(?P<pk>\d+)$',
        UpdateView.as_view(model=Universite, form_class=UniversiteForm),
        name='universite_update'),
)
开发者ID:auf,项目名称:auf_django_references,代码行数:17,代码来源:urls.py

示例9: url

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
                                       template_name='friendlib/private/mediarequest_detail.html'),
        name='mediarequest_detail'
    ),
    url(r'request/(?P<reqid>[0-9]+)/accept/$', mediarequest_set_accepted, name='mediarequest_accept'),
    url(r'request/(?P<reqid>[0-9]+)/decline/$', mediarequest_set_declined, name='mediarequest_decline'),
    url(r'request/(?P<reqid>[0-9]+)/borrow/$', mediarequest_set_borrowed, name='mediarequest_borrow'),
    url(r'request/(?P<reqid>[0-9]+)/return/$', mediarequest_set_returned, name='mediarequest_return'),

    url(r'^users/(?P<slug>[a-zA-Z]+)/$',
        DetailView.as_view(model=User,
                           slug_field='username',
                           template_name='friendlib/user/user_detail.html'),
        name='user_detail'),
    url(r'^users/(?P<slug>[a-zA-Z]+)/edit$',
        UpdateView.as_view(model=User,
                           slug_field='username',
                           success_url='./',
                           template_name='friendlib/user/user_edit.html'),
        name='user_update'),


    url(r'^books/create/$',
        BookCreateView.as_view(model=Book,
                               form_class=BookForm,
                               template_name='friendlib/media/book/book_create.html'),
        name='book_create'),
    url(r'^books/websearch/$', book_websearch, name='book_websearch'),
    url(r'^books/websearch/(?P<web_id>[a-zA-Z0-9-_]+)/$', book_websearch_detail, name='book_websearch_detail'),

    url(r'^books/(?P<pk>[0-9]+)/$',
        BookDetailView.as_view(model=Book,
                               template_name='friendlib/media/book/book_detail.html'),
开发者ID:steph-ben,项目名称:mediamis,代码行数:34,代码来源:urls.py

示例10: patterns

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]

urlpatterns = patterns('',
                       url(r'^node_list/$', ListView.as_view(
                           queryset=NetworkNode.objects.all(),
                           context_object_name='nodes',
                           template_name='django_dhcp/list.html'), name="node_list"),

                       url(r'^(?P<pk>[0-9]+)/$',
                           DetailView.as_view(
                               model=NetworkNode,
                               template_name='django_dhcp/detail.html',
                               context_object_name='node'
                           ), name="detail"),

                       url(r'^create/$', CreateView.as_view(
                           model=NetworkNode,
                           template_name='django_dhcp/create.html',),
                           name="create"),

                       url(r'^update/(?P<pk>[0-9]+)/$',
                           UpdateView.as_view(model=NetworkNode,
                                              template_name='django_dhcp/update.html'),
                           name="update"),
                       )

try:
    from djangoautoconf import create_tastypie_resource
    urlpatterns += (r'^api/node/', include(create_tastypie_resource(NetworkNode)))
except:
    pass
开发者ID:weijia,项目名称:django-dhcp,代码行数:32,代码来源:urls.py

示例11: url

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
        name='artist_list'),

    # Artist details, ex.: /myartists/artists/1/
    url(r'^artists/(?P<pk>\d+)/$',
        ArtistDetail.as_view(),
        name='artist_detail'),

    # Create a artist: /myartists/artists/create/
    url(r'^artists/create/$',
        ArtistCreate.as_view(),
        name='artist_create'),

    # Edit artist details, ex: /myartists/artists/1/edit/
    url(r'^artists/(?P<pk>\d+)/edit/$',
        UpdateView.as_view(
            model=Artist,
            form_class=ArtistForm,
            template_name='myartists/form.html'),
        name='artist_edit'),

    # Artist album details, ex: /myartists/artists/1/albums/1/
    url(r'^artists/(?P<pkr>\d+)/albums/(?P<pk>\d+)/$',
        DetailView.as_view(
            model=Album,
            template_name='myartists/album_detail.html'),
        name='album_detail'),

    # Create a artist album, ex: /myartists/artists/1/albums/create/
    url(r'^artists/(?P<pk>\d+)/albums/create/$',
        AlbumCreate.as_view(),
        name='album_create'),
开发者ID:joetds,项目名称:PracticaSiTW,代码行数:33,代码来源:urls.py

示例12: url

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
    # PROJECTS
    url(r'^projects/?$',
        ListView.as_view(queryset=Project.objects.all()),
                         name='project-list'),

    url(r'^projects/(?P<pk>\d+)/?$',
        DetailedListView.as_view(template_name="core/project_detail.html"),
        name='project-detail'),

    url(r'^projects/create/?$',
        CreateView.as_view(form_class=ProjectForm,
                           template_name="core/generic_form.html"),
                           name='project-create'),
    url(r'^projects/update/(?P<pk>\d+)/?$',
        UpdateView.as_view(queryset=Project.objects.all(),
                           template_name='core/generic_form.html',
                           form_class=ProjectForm),
        name='project-update'),

    # JOBS
    url(r'^jobs/?$', ListView.as_view(queryset=Job.objects.all()), name='job-list'),
    url(r'^jobs/(?P<pk>\d+)/(?P<status>[a-zA-Z_ ]+)?/?$',
        JobDetailedListView.as_view(template_name='core/job_detail.html'),
        name='job-detail'),
    url(r'^jobs/create/?$',
        CreateView.as_view(queryset=Job.objects.all(),
                           template_name='core/generic_form.html',
                           form_class=JobForm),
        name='job-create'),
    url(r'^jobs/update/(?P<pk>\d+)/?$',
        UpdateView.as_view(queryset=Job.objects.all(),
开发者ID:jateeter,项目名称:geoq-django,代码行数:33,代码来源:urls.py

示例13: PostCreateView

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
class PostCreateView(CreateView):
    model = Post
    form_class = PostForm
    template_name = 'money/add_post.html'

    def form_valid(self, form):
        posts = form.save(commit=False)
        posts.user = self.request.user
        posts.save()
        return super(PostCreateView, self).form_valid(form)



post_new = login_required(PostCreateView.as_view(model=Post, form_class=PostForm,template_name='money/add_post.html'))
post_edit = login_required(UpdateView.as_view(model=Post, form_class=PostForm,template_name = 'money/edit_post.html'))
post_delete = login_required(DeleteView.as_view(model=Post,success_url=reverse_lazy('money:post_list')))




class CommentCreateView(CreateView):
    model = Comment
    form_class = CommentForm
    template_name = 'money/add_comment.html'

    def form_valid(self, form):
        comment = form.save(commit=False)
        comment.post = get_object_or_404(Post, pk=self.kwargs['post_pk'])
        comment.comment_user = self.request.user
        comment.save()
开发者ID:TaeHyoungKwon,项目名称:class-azure-webapp-1st,代码行数:32,代码来源:views.py

示例14: render

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
    
    context ={
        "object_list":queryset,
        "title":"List"
    }
    
    return render(request,"notice/post_list.html",context)

def post_detail(request,pk):
    post = get_object_or_404(Post, pk=pk)
    post.hit += 1
    post.save()
    return render(request, 'notice/post_detail.html',{'post':post,})	


class CommentCreateView(CreateView):
    model = Comment
    form_class = CommentForm
    template_name = 'notice/add_comment.html'

    def form_valid(self, form):
        comment = form.save(commit=False)
        comment.post = get_object_or_404(Post, pk=self.kwargs['post_pk'])
        comment.author = self.request.user
        comment.save()
        return super(CommentCreateView, self).form_valid(form)


comment_new = login_required(CommentCreateView.as_view(model=Comment,form_class=CommentForm,template_name = 'notice/add_comment.html'))
comment_edit = login_required(UpdateView.as_view(model=Comment, form_class=CommentForm,template_name = 'notice/edit_comment.html'))
comment_delete = login_required(DeleteView.as_view(model=Comment,success_url=reverse_lazy('notice:post_list')))
开发者ID:TaeHyoungKwon,项目名称:class-azure-webapp-1st,代码行数:33,代码来源:views.py

示例15: url

# 需要导入模块: from django.views.generic import UpdateView [as 别名]
# 或者: from django.views.generic.UpdateView import as_view [as 别名]
		DetailView.as_view( 
			model=Dish,
			template_name='myrestaurants/dish_detail.html'),
		name='dish_detail'),


	# Create a restaurant, /myrestaurants/restaurants/create/
	url(r'^restaurants/create/$',
		RestaurantCreate.as_view(),
		name='restaurant_create'),


	# Edit restaurant details, ex.: /myrestaurants/restaurants/1/edit/
	url(r'^restaurant/(?P<pk>\d+)/edit/$',
		UpdateView.as_view(
			model=Restaurant,
			template_name='myrestaurants/form.html',
			form_class=RestaurantForm),
		name='restaurant_edit'),


	# Create a restaurant dish, ex.:/myrestaurants/restaurants/1/dishes/create/
	url(r'^restaurants/(?P<pk>\d+)/dishes/create/$',
		DishCreate.as_view(),
		name='dish_create'),


	# Edit restaurant dish details, ex.: /myrestaurants/restaurants/1/dishes/1/edit/
	url(r'^restaurants/(?P<pkr>\d+)/dishes/(?P<pk>\d+)/edit/$',
		UpdateView.as_view(
			model = Dish,
			template_name = 'myrestaurants/form.html',
开发者ID:Pol92,项目名称:Exemple-MyRecommendations,代码行数:34,代码来源:urls.py


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