views:

26

answers:

1

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

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

I do not understand a word of this. Please Bear with me I am new.

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 %}

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.

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

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.

A: 

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.

lazerscience