I am trying to run a project in which header has some menu links which are not loaded. The code to load the menu is as follows
<ul>
{% load menu_tags %}
{% for child in children %}
<li><a {% if forloop.first %} class="first" {% endif %}href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">{{ child.get_menu_title }}</a></li>
{% endfor %}
</ul>
It looks that the for loop is not running as the children array is empty. I am not getting the idea where to look for this children array. From where this array gets loaded. If django-cms query the database then what columns does it query.
The project was actually built on some older version of django 2.1. Now I am trying to run the project on django-cms 3.0.7. I am using mysql database and have imported the data.
As well as importing the data, you need to do some additional work.
See:
http://docs.django-cms.org/en/support-3.0.x/upgrade/2.1.html
http://docs.django-cms.org/en/support-3.0.x/upgrade/2.4.html
http://docs.django-cms.org/en/support-3.0.x/upgrade/3.0.html
There are some steps there that you can't leave out. In particular, see the notes in that second document about migrations, and about the cms moderator command.
Don't do anything without first making a database backup.
Related
I use last version of VSCode, I am on Windows10.
When I do the following:
{% extends 'base.html' %}
{% block content %}
<h1>Test About section</h1>
{% endblock %}
The code is automatically auto formatted when I save:
{% extends 'base.html' %} {% block content %}
<h1>Test About section</h1>
{% endblock %}
I am trying to deactivate it, but I have been unable to. This is what I've tried:
CTRL + Shift + P: 'Disable all Extensions' and also 'Disable all Extensions in Workspace'
In the Settings, the "editor.formatOnSave" is set to false (I have checked in User Settings, Settings for the Workpspace, Settings for Workspace JSON, etc)
Disabled Jinja and Prettier
Even tho I disabled my Extensions, when I hit [Save], the code is automatically formatted.
I am not sure where the settings get imported.
The project is new, I use Django, it's not linked to Git as well.
What I am doing wrong? I've been reading articles for the past hour but the issue keeps occurring, did I miss a setting or does a hidden setting get imported somewhere?
In trying to keep with DRY, I'm setting up my Django project HTML files now. I have successfully extracted most repeated information to my base.html page. On most (but not all) of my pages, my content is displayed within a general 'panel' which is basically just a container set-up with styling, but it's got a few div-tags to it so it looks a bit ugly and I'm having to type out the exact same code out several times on each page.
My idea was to extract this to a 'panel.html' then call it whenever I need it, for example some pages might just have one 'panel' whereas my dashboard (it's an administrative site) will have maybe 15+. So it seemed a better idea and cleaner to not have to type out all this code each time I need to set up a 'panel'.
My ideal page would look something like..
{% extends 'base.html' %}
{% block content %}
{% extends 'panel.html' %}
{% block panel_content %}
Panel content...
{% endblock panel_content %}
{% extends 'panel.html' %}
{% block panel_content %}
Second panel content
{% endblock panel_content %}
{% endblock content %}
I know I can't use extends multiple times but I'm using it just as an example for what it is I'm trying to achieve.
I am going to potentially have hundreds of these identical 'panels' across my site but each containing different content and it would be so much cleaner if I could just have one stored somewhere in a HTML file and call it however many times I need.
Is there a way to do this?
You can use include
{% include "panel.html" %}
I should mention that too many include statements create a performance issue.
I have set up Octopress with my Github account at http://acgrama.github.io/. The main page is a vanilla HTML, non-Octopress landing page, and the blog is set up in Octopress under source/blog.
(I have followed the instructions in the "Landing Page vs. Blog Index" section of http://octopress.org/docs/theme/template/)
Everything is ok, except when I go to http://acgrama.github.io/blog/ I see a link to the blog archives instead of the latest blog posts.
Some symptoms that I noticed: when I do rake generate, I get the following output:
## Generating Site with Jekyll
identical source/stylesheets/screen.css
Configuration file: /home/***/octopress/_config.yml
Source: source
Destination: public
Generating...
Pagination: Pagination is enabled, but I couldn't find an index.html page to use as the pagination template. Skipping pagination.
done.
Looking under source/blog/index.html, I understand that the posts in paginator.posts are iterated and shown (?), after which the Older/Newer and Blog Archives links are shown:
<div class="blog-index">
{% assign index = true %}
{% for post in paginator.posts %}
{% assign content = post.content %}
<article>
{% include article.html %}
</article>
{% endfor %}
<div class="pagination">
{% if paginator.next_page %}
<a class="prev" href="{{paginator.next_page_path}}">← Older</a>
{% endif %}
Blog Archives
{% if paginator.previous_page %}
<a class="next" href="{{paginator.previous_page_path}}">Newer →</a>
{% endif %}
</div>
</div>
These made me think that paginator.posts is empty for some reason, hence nothing happens in the first for loop and this is how only the Blog Archive link ends up being shown.
Am I doing anything wrong? Can this issue be solved at all?
I had the exact same issue and I found an answer based on your suspicion that paginator.posts was empty.
Update _config.yml and set the following:
paginate_path: "posts/:num"
to
paginate_path: "blog/posts/:num"
After that and a rake generate and rake preview, the /blog page showed my posts
This would lead me to believe that the paginator must be made aware of the subdirectory change for /blog. Really seems like something that should be in the docs
I'm probably missing something very obvious but can't see anything in the documentation. I have a carousel with a and each will hold an image. However I've added 6 but I want to add an if statement so if an Image has not been added you don't see a blank space, where there is no content inside the .
Here is what i've tried so far:
{% if "Carousel 1" %}
<li>
{% placeholder "Carousel 1" %}
</li>
{% endif %}
Attempt 2:
{% placeholder "Carousel 1" as cara1 %}
{% if cara1 %}
<li>
{{ cara1 }}
</li>
{% endif %}
Not sure if there is something differnt i need to be doing for the django-cms template tags?
Any help would be much appreciated. Docs here - http://docs.django-cms.org/en/latest/advanced/templatetags.html#placeholder
Not to be rude, but your approach is way, way off :)
Placeholders hold Content Plugins. Content Plugins are responsible for how they render their contents.
My advice would be to create or find a carousel content type plugin. This plugin will hold multiple images or "CarouselImage" model instances that you can iterate over, and also specify a template with which to render itself.
In this template resides the conditional statement you're wanting to check for. Placeholders are just that - places held for content plugins.
in wordpress your template automatically kicks out a '.current_page_item' on your menu.
I am wondering if there is a django way of doing this?
Well django is not wordpress and also not a cms, but it could be used as one.
In this case you have to do on your own, it will depends how you designed your templates?
There are many ways to do this and it depends on how you are doing your menus. I usually create my menu as a Django model. Then, in my template I compare the current path with the menu path. eg.
<ul class="menu">
{% for m in menuitems %}
<li{% if m.path == request.path }} class="current"{% endif %}>
{{ m.title }}
</li>
{% endfor %}
</ul>
Of cause, you would need to pass in menuitems into your view. To save adding in that into all my views, I usually create a template tag that fetches the menuitems variable for me.
So yes, completely possible... but it completely depends on how you decide to structure your menus and pages. Django is a web-framework, whereas Wordpress is a Blog engine.