Overriding template view function in Django app.

22 views
Skip to first unread message

sonu kumar

unread,
Oct 8, 2015, 12:40:13 PM10/8/15
to Django users
I have installed third party app(Mezzanine) whose urls are configured to use their view functions not View Class. Source code from mezzanine.blog.urls

       urlpatterns = patterns("mezzanine.blog.views",
16   url("^%stag/(?P<tag>.*)%s$" % _slashes, "blog_post_list",
21        name="blog_post_list_tag"),
18 ... 44)
As we can see they have configured blog URLs to use mezzanine.blog.views. Here we have few functions which are being called by URL dispatcher.  one of them is below.
       def blog_post_list(request, tag=None, year=None, month=None, username=None,
20                   category=None, template="blog/blog_post_list.html",
21                   extra_context=None):
22    """
23    Display a list of blog posts that are filtered by tag, year, month,
24    author or category. Custom templates are checked for using the name
25    ``blog/blog_post_list_XXX.html`` where ``XXX`` is either the
26    category slug or author's username if given.
27    """
I would like to override this function so that it will call my function to update context dictionary  or pass some more arguments to default function blog_post_list (it's having an argument extra_context so we can use this as external context) 

How can I achieve this ?
 Please provide complete details like do we have to modify urlpatterns then what should be changed, if we have to change view then what should be change ?
Reply all
Reply to author
Forward
0 new messages