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


Python detail.DetailView类代码示例

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


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

示例1: item_tracks

def item_tracks(request, item_id):
    return DetailView.as_view(
        request,
        queryset = Item.objects,
        object_id = item_id,
        template_name = "spindle/item_tracks.html",
        template_object_name = "item")
开发者ID:Krazylee,项目名称:spindle-code,代码行数:7,代码来源:views.py

示例2: get_context_data

 def get_context_data(self, **kwargs):
     context = DetailView.get_context_data(self, **kwargs)
     
             
     context['questions'] = self.object.get_ds_cau_hoi()
     
     return context
开发者ID:anhpt204,项目名称:tracnghiem,代码行数:7,代码来源:views.py

示例3: deck_detail

def deck_detail(request, deck_id=None):
    deck = get_deck_or_404(request.user, deck_id)

    if request.user.is_authenticated:
        # Redirect if the user is already subscribed to this deck.
        subscriber = deck.get_subscriber_deck_for_user(request.user)
        if subscriber:
            return redirect(subscriber.get_absolute_url())

    fact_tags = deck.fact_tags()

    detail_args = {
        'queryset': Deck.objects.filter(active=True),
        'template_object_name': 'deck',
        'extra_context': {
            'field_types': FactType.objects.get(id=1).fieldtype_set.all().order_by('ordinal'),
            'fact_tags': fact_tags,

            'textbook_source_form': TextbookSourceForm(),
            'textbook_form': TextbookForm(),
        },
        'object_id': deck_id,

    }
    #detail_args['extra_context'].update(study_options_context(request, deck_id=deck_id))
    return DetailView.as_view(request, **detail_args)
开发者ID:aehlke,项目名称:manabi,代码行数:26,代码来源:crud.py

示例4: get_context_data

 def get_context_data(self, **kwargs):
     context = DetailView.get_context_data(self, **kwargs)
     category_slug = self.request.GET.get('cat', None)
     category = get_category_by_slug(category_slug)
     context['category'] = category
     context['next_project'] = self.get_object().next(category_slug)
     context['previous_project'] = self.get_object().previous(category_slug)
     return context
开发者ID:mmoravcik,项目名称:folioport,代码行数:8,代码来源:views.py

示例5: get_context_data

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


        context['khthi'] = self.object.khthi
        context['thi_sinh'] = self.object.thi_sinh
        context['khthi_dangthi'] = KHTHI_DANGTHI

        return context
开发者ID:anhpt204,项目名称:hvhc,代码行数:9,代码来源:views.py

示例6: user_with_software

def user_with_software(request):
    """Deprecated"""
    userlist = User.objects.filter(software__isnull=False).distinct().order_by('username')
    return DetailView.as_view(request,
                                   paginate_by=20,
                                   queryset=userlist,
                                   template_name='software/user_list.html',
                                   extra_context=get_latest_news(),
                                   )
开发者ID:bairuiworld,项目名称:mloss,代码行数:9,代码来源:entry.py

示例7: software_all_dataformats

def software_all_dataformats(request):
    """Deprecated"""
    dataformatlist = DataFormat.objects.filter(name__isnull=False).distinct().order_by('slug')
    return DetailView.as_view(request,
                                   paginate_by=20,
                                   queryset=dataformatlist,
                                   template_name='software/dataformat_list.html',
                                   extra_context=get_latest_news(),
                                   )
开发者ID:bairuiworld,项目名称:mloss,代码行数:9,代码来源:entry.py

示例8: software_all_opsyss

def software_all_opsyss(request):
    """Deprecated"""
    opsyslist = OpSys.objects.filter(name__isnull=False).distinct().order_by('slug')
    return DetailView.as_view(request,
                                   paginate_by=20,
                                   queryset=opsyslist,
                                   template_name='software/opsys_list.html',
                                   extra_context=get_latest_news(),
                                   )
开发者ID:bairuiworld,项目名称:mloss,代码行数:9,代码来源:entry.py

示例9: preview

def preview(request, post_id, slug):
    try:
        post = Post.objects.select_related().get(pk=post_id, slug=slug)
        if post.is_published:
            return HttpResponsePermanentRedirect(post.get_absolute_url())
        else:
            return DetailView.as_view(
                model=Post, queryset=Post.objects.select_related().all(), object_id=post_id, context_object_name="post"
            )
    except Post.DoesNotExist:
        return HttpResponseRedirect(reverse("blogdor_archive"))
开发者ID:p-koryakin,项目名称:django-blogdor,代码行数:11,代码来源:views.py

示例10: get

    def get(self, request, *args, **kwargs):
        self.object.notificacoes.unread().filter(
            user=request.user).update(
                read=True,
                modified=timezone.now())

        if self.object.owner:
            return redirect(
                reverse_lazy('cmj.ouvidoria:solicitacao_interact',
                             kwargs=kwargs))

        return DetailView.get(self, request, *args, **kwargs)
开发者ID:cmjatai,项目名称:cmj,代码行数:12,代码来源:views.py

示例11: _post

def _post(request, year, slug):
    try:
        return DetailView.as_view(
            model=Post,
            queryset=Post.objects.published().select_related().filter(date_published__year=year),
            slug=slug,
            context_object_name="post",
        )
    except Http404, e:
        try:
            post = (
                Post.objects.published()
                .filter(date_published__year=year, slug__startswith=slug)
                .latest("date_published")
            )
            return HttpResponseRedirect(post.get_absolute_url())
        except Post.DoesNotExist:
            raise e
开发者ID:p-koryakin,项目名称:django-blogdor,代码行数:18,代码来源:views.py

示例12: get_object

    def get_object(self, queryset=None):
        """
        Supports ALL of the types of permalinks that we've defined in urls.py.
        However, it does require that either the id and the slug is available
        and unique.
        """
        if queryset is None:
            queryset = self.get_queryset()

        slug = self.kwargs.get(self.slug_url_kwarg, None)
        pk = self.kwargs.get(self.pk_url_kwarg, None)

        if pk is not None:
            # Let the DetailView itself handle this one
            return DetailView.get_object(self, queryset=queryset)
        elif slug is not None:
            # Let the TranslatedSlugMixin take over
            return super(ArticleDetail, self).get_object(queryset=queryset)

        raise AttributeError('ArticleDetail view must be called with either '
                             'an object pk or a slug')
开发者ID:Nekmo,项目名称:aldryn-newsblog,代码行数:21,代码来源:views.py

示例13: generic_wrapper

def generic_wrapper(request, *args, **kwargs):
    """
    This allows us to get the mediatype variable from the url and pass the
    correct queryset to the generic view
    """
    if 'mediatype' in kwargs and kwargs['mediatype'] in media_dict:
        mediatype = kwargs.pop('mediatype')
        queryset = media_dict[mediatype]['queryset']
        if 'extra_context' in kwargs:
            kwargs['extra_context'].update({'mediatype': mediatype})
        else:
            kwargs['extra_context'] = {'mediatype': mediatype}
        if 'enlarge' in kwargs:
            kwargs.pop('enlarge')
            kwargs['template_name'] = 'massmedia/enlarge_%s_detail.html' % mediatype
        if 'slug' in kwargs or 'object_id' in kwargs:
            return DetailView.as_view(queryset=queryset)(request, *args, **kwargs)
        if 'template_name' not in kwargs:
            kwargs['template_name'] = 'massmedia/list.html'
        return ListView.as_view(queryset=queryset)(request, *args, **kwargs)
    return HttpResponseNotFound()
开发者ID:callowayproject,项目名称:django-massmedia,代码行数:21,代码来源:urls.py

示例14: thread

def thread(request, forum, thread):
    """
	Increments the viewed count on a thread then displays the 
	posts for that thread, in chronological order.
	"""
    f = get_object_or_404(Forum, slug=forum)
    t = get_object_or_404(Thread, pk=thread)
    p = t.post_set.all().order_by("time")

    t.views += 1
    t.save()

    inputform = create_newpostform(request)
    extra = get_latest_news()
    extra["forum"] = f
    extra["form"] = inputform
    extra["thread"] = t
    extra["form_action"] = "reply/"

    return DetailView.as_view(
        request, paginate_by=10, queryset=p, template_name="community/thread.html", extra_context=extra
    )
开发者ID:kidzik,项目名称:mloss,代码行数:22,代码来源:views.py

示例15: reply

def reply(request, forum, thread):
    """
	If a thread isn't closed, and the user is logged in, post a reply
	to a thread. Note we don't have "nested" replies at this stage.
	"""
    f = get_object_or_404(Forum, slug=forum)
    t = get_object_or_404(Thread, pk=thread)
    p = t.post_set.all().order_by("-time")[:1]

    if t.closed:
        return HttpResponseRedirect("/accounts/login?next=%s" % request.path)

    if request.method == "POST":
        form = create_newpostform(request)

        if form.is_valid():
            if request.user.is_authenticated() or form.login(request):
                p = Post(thread=t, author=request.user, body=form.cleaned_data["body"], time=datetime.now())
                if form.data.has_key(u"post"):
                    p.save()
                    return HttpResponseRedirect(p.get_absolute_url())
                else:
                    return render_to_response(
                        "community/thread.html",
                        RequestContext(
                            request, {"forum": f, "form": form, "thread": t, "posting": p, "form_action": ""}
                        ),
                    )
    else:
        form = create_newpostform(request)

    return DetailView.as_view(
        request,
        paginate_by=10,
        queryset=p,
        template_name="community/thread.html",
        extra_context={"forum": f, "form": form, "thread": t, "form_action": ""},
    )
开发者ID:kidzik,项目名称:mloss,代码行数:38,代码来源:views.py


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