如何在DjangoCMS索引页面中添加一个href链接到另一个页面

时间:2022-01-07 21:12:07

I have a website developed using DjangoCMS and I tried to add a href to another page (site.com/en/blog). Unforunately none of my tries went well:

我有一个使用DjangoCMS开发的网站,我试图将href添加到另一个页面(site.com/en/blog)。不幸的是,我的尝试都没有顺利进行:

urls.py

urls.py

from __future__ import print_function
from cms.sitemaps import CMSSitemap
from django.conf.urls import *  # NOQA
from django.conf.urls.i18n import i18n_patterns
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.contrib import admin
from django.conf import settings

admin.autodiscover()

urlpatterns = i18n_patterns('',
    url(r'^admin/', include(admin.site.urls)),  # NOQA
    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
        {'sitemaps': {'cmspages': CMSSitemap}}),
    url(r'^select2/', include('django_select2.urls')),
    url(r'^', include('cms.urls')),
    url(r'^blog', include('cms.urls')),
)


# This is only needed when using runserver.
if settings.DEBUG:
    urlpatterns = patterns('',
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve',  # NOQA
            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
        ) + staticfiles_urlpatterns() + urlpatterns  # NOQA

index.html

的index.html

...
<li class="menu-item-has-children"><a href="blog.html">Blog</a>
    <ul class="sub-menu">
        <li><a href="blog-3col.html">3 Columns</a></li>
        <li><a href="blog-2col.html">2 Columns</a></li>
        <li><a href="blog-2col2.html">2 Columns with sidebar</a></li>
        <li><a href="blog-classic.html">Standard</a></li>
        <li><a href="blog-full.html">Fullwidth</a></li>
        <li><a href="blog-modern.html">Modern</a></li>
        <li><a href="blog-modern2.html">Modern 2</a></li>
        <li><a href="blog.html">Modern 2 Lite</a></li>
    </ul>
...

I've tried the following:

我尝试过以下方法:

<a href="blog.html">Blog</a> or
<a href="{% url 'blog.html' %}">Blog</a> or
<a href="{% url blog.html %}">Blog</a>

博客博客博客

But every time I get 404-Page not found. I am sure that the page exists at that path.

但每次我都找不到404页面。我确信该页面存在于该路径中。

Any hints, please ?

有什么提示吗?

1 个解决方案

#1


1  

Instead of manually writing the menus yourself, you should use the {% show_menu %} template tag in django CMS.

您应该使用django CMS中的{%show_menu%}模板标记,而不是自己手动编写菜单。

If you need to have non-CMS menu nodes too, look at how to extend the menu in django CMS.

如果您还需要非CMS菜单节点,请查看如何在django CMS中扩展菜单。

#1


1  

Instead of manually writing the menus yourself, you should use the {% show_menu %} template tag in django CMS.

您应该使用django CMS中的{%show_menu%}模板标记,而不是自己手动编写菜单。

If you need to have non-CMS menu nodes too, look at how to extend the menu in django CMS.

如果您还需要非CMS菜单节点,请查看如何在django CMS中扩展菜单。