使用django-page-cms显示页面内容 [英] Displaying page content using django-page-cms

查看:67
本文介绍了使用django-page-cms显示页面内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些模板页面中显示模型中的某些内容。

I would like to display some content located in my models in some of my template pages.

我正在使用django-page cms

I am using django-page cms

在文档视图中不用于显示内容。而是使用现成的模板标签。

In the documentation views are not used to display content. Instead ready made template tags are used.

http://packages.python.org/django-page-cms/display-content.html

我不明白一句话。

我要做的就是以这种方式在模板中显示位于模型中的一些信息。

All I want to do is display some info located in my models inside a template this manner..


   {% if latest_news_list %}          
      {% for news in latest_news_list %} 
           <li><h3>{{ news.title }}</h3></li>
           <li><p>{{ news.body }}</p></li>
      {% endfor %}


因为视图不是我不能使用,如果latest_news_list。
我需要以某种方式使我的模型使用django-page cms而不是常规视图显示在模板中。文档指出为此使用某种模板标记。

Since views are not used I cannot use if latest_news_list. I need to somehow get my models to display in the templates using django-page cms and NOT regular views. The documentation states to use some kind of template tag for this.

请问有人可以向我解释如何做。

下面的现成模板标签的解释也将不胜感激...
* get_content
* show_content
* get_page
* show_absolute_url

Could somebody please explain to me how to do this.
And a clear concise explanation of the following ready-made template tags would also be appreciated... * get_content * show_content * get_page * show_absolute_url

摘自。http://packages.python.org/django-page-cms/display-content.html

taken from.http://packages.python.org/django-page-cms/display-content.html

我需要显示包含的信息以我上面强调的方式使用以下模型。非常感谢您的帮助。我的模型如下。

I need to display info contained using the following models in the manner I have highlighted above. Thank you very much for your help. my models are as follows.

class Body(models.Model):
    type = models.ForeignKey(Content)
    title = models.CharField(max_length=100)
    published = models.DateTimeField(default=datetime.now)
    body = tinymce_models.HTMLField("Main content")

正如我所说的,我对此很陌生,请使解释尽可能简单。

As I have stated I am very new to this please make explanations as simple as possible.

推荐答案

您提到的模板标签应该显示来自cms的内容。如果您要包括来自应用程序的数据,则应查看此部分链接文本

The template tags you mentioned are supposed to display content coming from the cms. If you want to include data coming from your app, you should see this sectionlink text.

def extra_context():
    from myapp.models import Body
    items = Body.object.all()
    return {'items': items}

PAGE_EXTRA_CONTEXT = extra_context


{% if items %}
    <ul>
        {% for item in items %}
        <li>{{ item.title }} </li>
        {% endfor %}
    <ul>
{% endif %}

或者,如果要使用应用程序的视图,请参见

Or, if you want to use your app's view, see this.

这篇关于使用django-page-cms显示页面内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆