Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog content is missing. #524

Closed
AtulCIS opened this issue Nov 22, 2019 · 7 comments · Fixed by #631
Closed

Blog content is missing. #524

AtulCIS opened this issue Nov 22, 2019 · 7 comments · Fixed by #631

Comments

@AtulCIS
Copy link

AtulCIS commented Nov 22, 2019

Hi I have setup the django cms blog. I have created the blog post. The content is proper in my listing page but blog details page does not having any content. Pleas help on this.
I have found that we can add it on text from front end. I can create a blog post from front end but edit buttons is disabled on all posts.
I have tried BLOG_USE_PLACEHOLDER=False setting to enable text in admin end for post but that is not working.

@yakky
Copy link
Member

yakky commented Dec 4, 2019

@AtulCIS djangocms-blog primary content editing is using django CMS plugins via frontend editor.
If I understand correctly this is working, right? In case you need further information regarding how django CMS works, you can refer to their documentation (https://django-cms.readthedocs.io/en/latest/introduction/index.html and https://django-cms.readthedocs.io/en/latest/user/index.html )
By default the abstract content you add via the admin is only shown in the listing page, but you can customize the template to display it on the detail too
What happens if you set BLOG_USE_PLACEHOLDER=False? You should see an additional field in the admin. Bear in mind that the setting is mainly managed via the apphook config (http://localhost:8000/admin/djangocms_blog/blogconfig/)

@pau1a
Copy link

pau1a commented Sep 5, 2020

Hey @yakky can you tell me exactly where in the Django CMS config this will be found in the CMS frontend editor. I don't see any clue in there and I have exactly the same problem.
I can hack the /includes/post_detail.html file to show me anything I want it to but the problem is this file is used by both the post_list.html and the post_detail.html so if I hack it to show me the full post then that's not gonna work for the post list view. In any case this isnt the way to do it of course.
I see the {% if post.app_config.use_placeholder %} but I see no clues in the documentation about how to make this happen. You mention the front end but I see no placeholder there that I can work with.

I just double checked after reading a bit more about render_model and went to the post page to see if I could use the double click to edit facility and it took me into the post again but I see no option to make the post visible.

Edit:

Ive been doing some more digging and it seems lime my settings file is completely different to the one in this repository. For example for the line relating to the BLOG_USE_PLACEHOLDER setting I have this:

    `'BLOG_USE_PLACEHOLDER': getattr(settings, 'BLOG_USE_PLACEHOLDER', True),`

however in the remainder of the code I have no further reference to BLOG_USE_PLACEHOLDER. In fact the only reference I have to PLACEHOLDER is in references to USE_PLACEHOLDER

For example in my views.py file by grepping for 'get_setting' then 'PLACEHOLDER' I see the following:

../../django/myprojectenv/lib/python3.5/site-packages/djangocms_blog/views.py:19:from .settings import get_setting
../../django/myprojectenv/lib/python3.5/site-packages/djangocms_blog/views.py:114:        context['use_placeholder'] = get_setting('USE_PLACEHOLDER')

I ran my install via pip.

From init.py I see Im running :

# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

__author__ = 'Iacopo Spalletti'
__email__ = 'i.spalletti@nephila.it'
__version__ = '1.1.1'

default_app_config = 'djangocms_blog.apps.BlogAppConfig'

and yet if I examine the value of the context returned by get_context_data in PostDetailView class in views.py I see this:

{'post': <Post: Django test>, 'use_placeholder': True, 'instant_article': False, 'view': <djangocms_blog.views.PostDetailView object at 0x7f1d341eb240>, 'meta': <meta.views.Meta object at 0x7f1d3411ba20>, 'object': <Post: Django test>}

use_placeholder changes appropriately from True to False as I set it in my project settings file.

@yakky
Copy link
Member

yakky commented Sep 5, 2020

@pau1a BLOG_USE_PLACEHOLDER setting is read by get_setting("USE_PLACEHOLDER") (see https://github.com/nephila/djangocms-blog/blob/develop/djangocms_blog/views.py#L100) and is on by default.

In case you want to use django CMS plugins you don't have to set anything, after creating the blog post from the admin (or from the django CMS toolbar), you can just visit the blog post page (example: http://localhost:8000/blog/my-post/) as admin in edit mode and add django CMS plugin. For a primer on django CMS see its editor documentation http://docs.django-cms.org/en/latest/user/index.html

@pau1a
Copy link

pau1a commented Sep 6, 2020

Hey @yakky thanks for your reply. Ive been working through the operation of the blog application. Hope to be able to understand this soon but I certainly dont get any post content when I visit the blog post page. The div with the contents/abstract is empty.

Also you say "as admin in edit mode and add django CMS plugin". I dont see any blog plugins available apart from the following:

Archive
Author Blog Articles
Author Blog Articles List
Categories
Latest Blog Articles
Latest Blog Articles - Cache
Tags

Ive also tried adding new bootstrap plugins to create a nice div to drop a "cms blog" plugin into but that doesnt change the problem. I'll keep digging and learning. Thanks for your support and your work.

@yakky
Copy link
Member

yakky commented Sep 6, 2020

Those are the plugins provided by djangocms-blog package, but you will want to install django cms core plugins (like djangocms-text-ckeditor, djangocms-picture etc) to add content to blog posts
If you installed django CMS by hand, I suggest you to check the relevant django CMS documentation http://docs.django-cms.org/en/latest/how_to/install.html#adding-content-handling-functionality about installing content plugins

This was referenced Sep 6, 2020
@pau1a
Copy link

pau1a commented Sep 6, 2020

Hey @yakky thanks for the advice. I have all the necessary dependent stuff installed and I could force the display of a post if I hacked the template.

I think I have made a breakthrough of sorts. Looking at the translations for the Post class in models.py I could see that this was where the template should have been picking up the post_text from but it wasnt delivering anything to the front end so I saw that abstract was another option, tried that and it works just fine.

I replaced:

    {% if post.app_config.use_placeholder %}
        <div class="blog-content">{% render_placeholder post.content %}</div>
    {% else %}
        <div class="blog-content">{% render_model post "post_text" "post_text" "" "safe" %}</div>
    {% endif %}

with

    {% if post.app_config.use_placeholder %}
        <div class="blog-content">{% render_placeholder post.content %}</div>
    {% else %}
        <div class="blog-content">{% render_model post "abstract" "abstract" "" "safe"  %}</div>
    {% endif %}

and now my page to display a single post displays the full post properly.

I wonder why post_text was producing nothing.

@pau1a
Copy link

pau1a commented Sep 6, 2020

OMG I think I've worked this out.

I hadn't realised that "abstract" and "post text" were two different fields. I don't think I even saw the second area for post text but its hard to say now given all the changes I've made.

Still I've learned a lot about this plugin and its working now so all's well. Thanks so much for your advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants