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


Python edit.CreateView类代码示例

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


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

示例1: test_mixin_get_queryset

    def test_mixin_get_queryset(self):
        self.moxx.StubOutWithMock(UserModelManager, 'filter_user_objects')
        UserModelManager.filter_user_objects(self.user).AndReturn('object')
        self.moxx.StubOutWithMock(CreateView, 'get_queryset')
        CreateView.get_queryset().AndReturn('pass')

        self.assertEqual(self.view.queryset, None)
        self.moxx.ReplayAll()
        self.view.get_queryset()
        self.moxx.VerifyAll()
        self.assertEqual(self.view.queryset, 'object')
开发者ID:renoc,项目名称:personal-classalchemy,代码行数:11,代码来源:tests.py

示例2: test_dwmixin_get_success_url

    def test_dwmixin_get_success_url(self):
        self.moxx.StubOutWithMock(CreateView, 'get_success_url')
        CreateView.get_success_url().AndReturn('pass')
        self.moxx.StubOutWithMock(messages, 'success')
        messages.success(self.request, 'Developer Class Updated.')

        self.assertEqual(self.view.success_url, None)
        self.moxx.ReplayAll()
        self.view.get_success_url()
        self.moxx.VerifyAll()
        self.assertEqual(self.view.success_url, '/dwclass/1')
开发者ID:renoc,项目名称:personal-classalchemy,代码行数:11,代码来源:tests.py

示例3: get_context_data

 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['idfase'] = self.kwargs['idfase']
     context['action'] = reverse('item_crear', kwargs={'idfase': self.kwargs['idfase']})
     if self.ocurrio_error :
         context['nodefault'] = '__panel.html'
     return context
开发者ID:nelsondspy,项目名称:projectmn,代码行数:7,代码来源:view_item.py

示例4: get_context_data

 def get_context_data(self, **kwargs):
     context = CreateView.get_context_data(self, **kwargs)
     context['action'] = reverse('rol_permisos')
     if self.templ_base_error:
         context['nodefault'] = self.templ_base_error
         context['errormensaje'] = self.mensaje
     return context
开发者ID:nelsondspy,项目名称:projectmn,代码行数:7,代码来源:views.py

示例5: render_to_response

    def render_to_response(self, context):

        if self.request.is_ajax():
            return JSONHybridProcessFormViewMixin.render_to_response(self,
                                                                     context)

        return CreateView.render_to_response(self, context)
开发者ID:snowman-st,项目名称:edu-back,代码行数:7,代码来源:response.py

示例6: get_context_data

    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)
        context["action"] = reverse("relacion_crear", kwargs={"idproyecto": self.kwargs["idproyecto"]})
        if not self.valido:
            context["nodefault"] = "__panel.html"

        return context
开发者ID:nelsondspy,项目名称:projectmn,代码行数:7,代码来源:view_itemrelacion.py

示例7: get_form

 def get_form(self, form_class):
     form = CreateView.get_form(self, form_class)
     #obtiene el proyecto
     self.rolproyecto = get_object_or_404(RolProyecto, pk=self.kwargs['idrolproyecto'])
     #obtiene solo las fases que tiene el proyecto. en lugar de todas las fases.
     proyecto = get_object_or_404(Proyecto,pk=self.rolproyecto.proyecto_id )
     form.fields['fase'].queryset = Fase.objects.filter(idproyecto=proyecto)
     return form
开发者ID:nelsondspy,项目名称:projectmn,代码行数:8,代码来源:views.py

示例8: get_form

    def get_form(self, form_class):
        form = CreateView.get_form(self, form_class)
        #carga el selector con tipos de item que no son supertipo
        opciones = [(item.pk, item.idfase.__str__()[0:10] +' - '+ item.nombre) \
                    for item in ItemTipos.objects.filter(es_supertipo=False)]
        form.fields['itemtipoimport'].choices = opciones

        return form
开发者ID:nelsondspy,项目名称:projectmn,代码行数:8,代码来源:view_itemtipo.py

示例9: get_form

 def get_form(self, form_class):
     product = self.get_context_data()['product']
     if product.status == Product.COURIER:
         form_class = CourierCommentForm
     elif self.request.user.is_staff:
         form_class = StaffCommentForm
     else:
         form_class = CommentForm
     return CreateView.get_form(self, form_class)
开发者ID:owad,项目名称:service,代码行数:9,代码来源:views.py

示例10: form_valid

 def form_valid(self, form):
     #verifica que solo exista un solo registro del par (usuario, proyecto)
     miembro = ComiteProyecto.objects.filter(proyecto=form.instance.proyecto, \
                                             usuario =form.instance.usuario)
     if miembro.count()>0 :
         messages.error(self.request, 'ya existe este miembro para este proyecto')
         self.ocurrio_error = True
         return self.form_invalid(form)
     
     return CreateView.form_valid(self, form)
开发者ID:nelsondspy,项目名称:projectmn,代码行数:10,代码来源:view_comite.py

示例11: get_initial

    def get_initial(self):
        self.initial = {'parent': self.parent}

        cod__max = Classe.objects.filter(
            parent=self.parent).order_by('codigo').aggregate(Max('codigo'))

        self.initial['codigo'] = cod__max['codigo__max'] + \
            1 if cod__max['codigo__max'] else 1

        return CreateView.get_initial(self)
开发者ID:cmjatai,项目名称:cmj,代码行数:10,代码来源:views.py

示例12: get_context_data

 def get_context_data(self, **kwargs):
     data = CreateView.get_context_data(self, **kwargs)
     product = get_object_or_404(Product, pk=self.kwargs['pk'])
     data['product'] = product
     data['user'] = self.request.user
     if product.courier:
         data['courier'] = Courier.objects.get(pk=product.courier)
     data['comment_list'] = product.comment_set.all().order_by('id')
     data['comment_form'] = CommentForm(initial={'user': self.request.user, 'product': product})
     data['hardware_comment_form'] = CommentForm(initial={'user': self.request.user, 'product': product})
     return data
开发者ID:owad,项目名称:service,代码行数:11,代码来源:views.py

示例13: form_valid

 def form_valid(self, form):
     #verificamos que aun no este asignado:
     #el usuario  a un  proyecto con algun rol
     qs = RolProyecto.objects.filter(usuario=form.instance.usuario
                                ).filter(proyecto=form.instance.proyecto)
     #si ya esta asignado enviamos un mensaje de error
     if (qs.count() > 0):
         messages.error(self.request, 'Esta asignacion ya existe, solo puede asignar \
         un rol a un usuario para un proyecto.')
         self.templ_base_error = "__panel.html"
         return self.form_invalid(form)
     return CreateView.form_valid(self, form)
开发者ID:nelsondspy,项目名称:projectmn,代码行数:12,代码来源:views.py

示例14: get_context_data

    def get_context_data(self, **kwargs):
        context = CreateView.get_context_data(self, **kwargs)

        tipo = int(self.request.GET.get('tipo', '10'))

        tipos = Solicitacao.TIPO_SOLICITACAO_CHOICE

        context['title'] = _(
            'Registar uma Solicitação: (%s)') % tipos.triple_map[tipo]['text']

        context['bg_title'] = opts_bg[tipo]

        return context
开发者ID:cmjatai,项目名称:cmj,代码行数:13,代码来源:views.py

示例15: form_valid

    def form_valid(self, form):
        note = form.save(commit=False)
        note.author = self.request.user

        model = self.request.POST['content_type']
        if model not in ['account', 'contact', 'deal', 'case']:
            raise BaseException("Invalid content_type")

        object_id = self.request.POST['object_id']
        content_type = ContentType.objects.get(model=model)
        note.subject = content_type.get_object_for_this_type(id=object_id)
        note.save()
        return CreateView.form_valid(self, form)
开发者ID:noordzij,项目名称:hellolily,代码行数:13,代码来源:views.py


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