poblem mentioned at the end.
so i installed pinax blog app and added to my installed app , migrated and set up all its dependencies. i then added it to the urlpatterns in my project :
urlpatterns = [
path('admin/', admin.site.urls),
url(r"^blog/", include("pinax.blog.urls", namespace="pinax_blog")),
url(r"^ajax/images/", include("pinax.images.urls", namespace="pinax_images")),
]
the urpatterns in pinax.blog.urls are :
urlpatterns = [
url(r"^$", BlogIndexView.as_view(), name="blog"),
url(r"^section/(?P<section>[-\w]+)/$", SectionIndexView.as_view(), name="blog_section"),
url(r"^post/(?P<post_pk>\d+)/$", StaffPostDetailView.as_view(), name="blog_post_pk"),
url(r"^post/(?P<post_secret_key>\w+)/$", SecretKeyPostDetailView.as_view(), name="blog_post_secret"),
url(r"^feed/(?P<section>[-\w]+)/(?P<feed_type>[-\w]+)/$", blog_feed, name="blog_feed"),
# authoring
url(r"^manage/posts/$", ManagePostList.as_view(), name="manage_post_list"),
url(r"^manage/posts/create/$", ManageCreatePost.as_view(), name="manage_post_create"),
url(r"^manage/posts/(?P<post_pk>\d+)/update/$", ManageUpdatePost.as_view(), name="manage_post_update"),
url(r"^manage/posts/(?P<post_pk>\d+)/delete/$", ManageDeletePost.as_view(), name="manage_post_delete"),
url(r"^ajax/markdown/preview/$", ajax_preview, name="ajax_preview")
]
the BlogIndexView:
class BlogIndexView(ListView):
model = Post
template_name = "pinax/blog/blog_list.html"
search_parameter = "q"
paginate_by = settings.PINAX_BLOG_PAGINATE_BY
def get_current_section(self):
return "all"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
"current_section": self.get_current_section(),
"search_term": self.search_term()
})
return context
def search_term(self):
return self.request.GET.get(self.search_parameter)
def search(self, posts):
q = self.search_term()
if q:
posts = posts.filter(
Q(title__icontains=q) | Q(teaser_html__icontains=q) | Q(content_html__icontains=q)
)
return posts
def get_queryset(self):
blog = hookset.get_blog(**self.kwargs)
qs = Post.objects.current().filter(blog=blog).select_related("section", "blog")
return self.search(qs)
Question:
when i run sever and go to http://127.0.0.1:8000/blog/ the BlogIndexView should work according to first url pattern of pinax_blog's url pattern and the template_name = "pinax/blog/blog_list.html" should be loaded. but the template doesnt load a different template called site_base.html loads instead . any ideas why?
blog_list.htmlextendsblog_base.htmlwhich in turn extendssite_base.html.If you track
site_base.htmldown (perhaps, in your virtual env) you'll find out it doesn't provide the blocks to be filled out by the templates that extend it. Rather, it contains the comment:So, you're to provide a
site_base.htmlin your project, which will override the stub provided by pinax.For starters, your
site_base.htmlcan provide the body block:Save it in
<your-app>/templates/site_base.html, and make sure to add your app toINSTALLED_APPS(in your project'ssettings.py) beforepinax.blogso that the template loader discovers its templates before the ones they are to override inpinax-blog.