Python django.views.generic.detail.DetailView() Examples

The following are 1 code examples of django.views.generic.detail.DetailView(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.views.generic.detail , or try the search function .
Example #1
Source File: views.py    From djanblog with MIT License 6 votes vote down vote up
def get_context_data(self, **kwargs):
        context = super(DetailView, self).get_context_data(**kwargs)
        current = self.object
        current.increase_click()

        try:
            next_post = current.get_next_by_pub_date(hidden=False)
        except:
            next_post = None

        try:
            previous_post = current.get_previous_by_pub_date(hidden=False)
        except:
            previous_post = None

        context['next'] = next_post
        context['previous'] = previous_post
        context['title'] = current.title

        return context