Django Zinnia无法链接到主页中的“weblog”

时间:2015-04-02 05:49:21

标签: python html django zinnia

我使用Django Edge(v2.0)模板并创建了一个网站,这是我的主要项目,它的标题是:网站。在项目中,我开始实施一个博客,并安装了Zinnia。我有以下内容:

Python 3.4.2和Django 1.7.7

我根据安装文档安装了Zinnia,包括所有列出的依赖项,并且它可以正常工作。如果我导航到127.0.0.0,则会转到"主页"网站项目。如果我浏览127.0.0.0/weblog/,它会带我去Zinnia的#34;主页"的博客。这一切都有效。但是,在网站的主页(home.html)上,我尝试创建指向/ weblog的链接,但似乎无法使其正常运行。我确定它只是语法,而且我缺乏知识。

以下是我的项目结构:

├── LICENSE.txt
├── README.md
├── docs
│   └── index.md
├── requirements.txt
└── src
    ├── Website
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── settings
    │   ├── urls.py
    │   ├── views.py
    │   └── wsgi.py
    ├── accounts
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── templates
    │   ├── urls.py
    │   └── views.py
    ├── manage.py
    ├── profiles
    │   ├── __init__.py
    │   ├── __pycache__
    │   ├── templates
    │   ├── urls.py
    │   └── views.py
    ├── static
    │   ├── bootstrap
    │   └── site
    ├── templates
    │   ├── about.html
    │   ├── base.html
    │   ├── home.html
    └── zinnia
        ├── __init__.py
        ├── __pycache__
        ├── managers.py
        ├── markups.py
        ├── static
        ├── templates
        ├── urls
        ├── views

这是我的主要内容:urls.py:

urlpatterns = patterns(
    '',
    url(r'^$', views.HomePage.as_view(), name='home'),
    url(r'^', include(accounts.urls, namespace='accounts')),
    url(r'^users/', include(profiles.urls, namespace='profiles')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^weblog/', include('zinnia.urls', namespace='zinnia')),
    url(r'^comments/', include('django_comments.urls')),

)

在网站的家中,使用home.html,我可以创建按钮,将我引导到其他页面,如下所示:

<a class="btn btn-default" href="{% url 'accounts:login' %}" role="button">Log in</a>

我基本上想要一个&#34;博客&#34;按钮,在我的主页上,将我重定向到127.0.0.0/weblog/,所以我这样做:

<a class="btn btn-default" href="{% url 'zinnia:weblog' %}" role="button">Blog</a>

我收到此错误:

Reverse for 'weblog' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

了解更多信息:

In template /Website/src/templates/home.html, error at line 59
59       <a class="btn btn-default" href="{% url 'zinnia:weblog' %}" role="button">Log in</a>

任何帮助将不胜感激,谢谢你提前。

1 个答案:

答案 0 :(得分:2)

我可能已经迟到了,但万一有人需要这个,这里是你如何得到你的博客根的网址

<a href="{% url 'zinnia:entry_archive_index' %}">Weblog</a>
相关问题