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


Python generic.UpdateView类代码示例

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


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

示例1: __init__

    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,代码行数:26,代码来源:laboratory.py

示例2: python_group_crud

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,代码行数:12,代码来源:views.py

示例3: user_register

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,代码行数:12,代码来源: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: user_register

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,代码行数:14,代码来源:views.py

示例6: get_object

 def get_object(self):
     word = UpdateView.get_object(self, queryset=None)
     if word.is_noun:
         self.template_name = 'noun_form.html'
         self.form_class = NounForm
         return word.noun
     if word.is_verb:
         self.template_name = 'verb_form.html'
         self.form_class = VerbForm
         return word.verb
     if word.is_adjective:
         self.template_name = 'adjective_form.html'
         self.form_class = AdjectiveForm
         return word.adjective
     self.template_name = 'word_form.html'
     self.form_class = WordForm
     return word
开发者ID:jagadeeshe,项目名称:learndutch,代码行数:17,代码来源:views.py

示例7: user_profile_upd

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,代码行数:19,代码来源:views.py

示例8: get

    def get(self, request, *args, **kwargs):
        """ Get Outing to update
        """
        self.object = self.get_outing()

        if self.object.status == FINISHED:
            raise Http404

        if self.object.user != self.request.user:
            if self.messages.get("permission_denied"):
                messages.add_message(
                    self.request,
                    self.messages["permission_denied"]["level"],
                    self.messages["permission_denied"]["text"],
                )

            return HttpResponseRedirect(self.get_success_url())

        form_class = self.get_form_class()
        form = self.get_form(form_class)
        ctx = RequestContext(self.request, self.get_context_data(form=form))
        return UpdateView.render_to_response(self, ctx)
开发者ID:Billybob,项目名称:RandoAmisSecours,代码行数:22,代码来源:outing.py

示例9: url

        context_object_name="arenas",
    ), name="golfstats-courses-arenas"),

    url(r'^arenas/create/$', CreateView.as_view(
        model=Arena,
        success_url=reverse_lazy('golfstats-courses-arenas'),
    ), 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"),
开发者ID:jonejone,项目名称:golfstats,代码行数:30,代码来源:urls.py

示例10: url

    url(r'^features/create/?$',
        login_required(CreateFeatures.as_view()),
        name='feature-create'),

    url(r'^features/edit/?$',
        login_required(EditFeatures.as_view()),
        name='feature-edit'),

    url(r'^feature-types/create/?',
        login_required(CreateView.as_view(template_name='core/generic_form.html',
                           form_class=FeatureTypeForm)),
        name='feature-type-create'),

    url(r'^feature-types/update/(?P<pk>\d+)/?$',
        login_required(UpdateView.as_view(template_name='core/generic_form.html',
                           queryset=FeatureTypeForm.Meta.model.objects.all(),
                           form_class=FeatureTypeForm)),
        name='feature-type-update'),

    url(r'^feature-types/delete/(?P<pk>\d+)/?$',
        login_required(FeatureTypeDelete.as_view()),
        name='feature-type-delete'),

    # Map list
    url(r'^maps/?$', MapListView.as_view(queryset=Map.objects.all()),
                                              name='map-list'),

    url(r'^maps/delete/(?P<pk>\d+)/?$',
        login_required(MapDelete.as_view()),
        name='map-delete'),
开发者ID:nudtchengqing,项目名称:geoq,代码行数:30,代码来源:urls.py

示例11: url

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,代码行数:31,代码来源:urls_sponsorpackages.py

示例12: render_to_response

 def render_to_response(self, context):
     if permissions.can_user_edit_page(self.request.user, context['page']):
         return UpdateView.render_to_response(self, context)
     else:
         return HttpResponseForbidden('You do not have permission to edit this page.')
开发者ID:nikki603,项目名称:Stars-CMS,代码行数:5,代码来源:views.py

示例13: url

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', mainpage, name='home'),
	#BRANDS
    url(r'^brands/$', brands , name='brands'),
    url(r'^brands/view/(?P<brand_name>\w+)/$', brand_detail , name='brand detail'),
    url(r'^brands/view/(?P<brand_name>\w+)/models/$', brand_models , name='brand models'),
    url(r'^brands/add/$', brands_add , name='add brand'),


	#MODELS
    url(r'^models/$', models , name='models'),
    url(r'^models/view/(?P<pk>\d+)/$', model_detail , name='model detail'),
    url(r'^models/add/$', model_add , name='add model'),
    url(r'^models/edit/(?P<pk>\d+)/$',UpdateView.as_view(model = Model,template_name = 'add_form_user.html',form_class = ModelFormEdit, success_url="/userpanel/my-laptops/"),name='laptop edit'),
    url(r'^models/delete/(?P<pk>\d+)/$', models_delete , name='delete model'),

	#COMPONENTS
    url(r'^components/$', components , name='components'),
    url(r'^components/view/(?P<pk>\d+)/$', component_detail , name='Component Detail'),
    url(r'^components/add/$', components_add , name='add component'),
    url(r'^components/edit/(?P<pk>\d+)/$',UpdateView.as_view(model = Component,template_name = 'add_form.html',form_class = EditComponent,success_url="/components/"),name='Component Edit'),


	#Specifications
    url(r'^specifications/$', specifications_detail_all , name='Specification Detail all'),
    url(r'^specifications/view/(?P<spec_id>\w+)/$', specifications_list , name='specifications list'),
    url(r'^specifications/add/$', specifications_add , name='add specification'),
    url(r'^specifications/edit/(?P<pk>\d+)/$',UpdateView.as_view(model = Specification,template_name = 'add_form.html',form_class = EditSpecification,success_url="/specifications/"),name='Specifications Edit'),
开发者ID:eduardmiro,项目名称:notebookcompare,代码行数:29,代码来源:urls.py

示例14: url

    # 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,代码行数:31,代码来源:urls.py

示例15: get_context_data

 def get_context_data(self, **kwargs):
     context = UpdateView.get_context_data(self, **kwargs)
     context['laboratory'] = self.object.pk
     return context
开发者ID:solvo,项目名称:organilab,代码行数:4,代码来源:laboratory.py


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