1

I've installed Flatpages and have a few pages set up to load off of specific templates. Though the templates I'm using now are doing just fine, I'd love to be able to easily make parts of it editable by other non-technical admins. So I've been wondering—every time I go into Django admin for Flatpages, I see this big text area for content:

Django admin for Flatpages

Is there some way I can use that to make parts of my template editable by others? As you can see, I tried saving some text in there to see what happened, and it didn't show up on the page. I also tried creating a Flatpage without pointing to a specific template (besides default.html) and put HTML into the content field, but again the content didn't show up. What is the purpose of the content field?

Michelle Glauser
  • 1,097
  • 16
  • 28
  • 1
    Er, the content field is the main content of the flatpage. – Daniel Roseman Mar 10 '15 at 15:56
  • How are you currently using flatpages, if not to render content? Genuine curiosity. – rnevius Mar 10 '15 at 15:59
  • All my content is currently in the template it's pointing to. I guess catavaran's answer means that the content will show up if I put it in template tags. – Michelle Glauser Mar 10 '15 at 16:32
  • @MichelleGlauser that's correct. [Flatpage templates are passed a single context variable, flatpage, which is the flatpage object.](https://docs.djangoproject.com/en/1.7/ref/contrib/flatpages/#flatpage-templates) – rnevius Mar 10 '15 at 17:03

1 Answers1

1

Just output this field in the template. For example:

{% extends 'base.html' %}

{% block title %}{{ flatpage.title }}{% endblock %}

{% block content %}    
    <h1>{{ flatpage.title }}</h1>    
    {{ flatpage.content|safe }}    
{% endblock %}
catavaran
  • 44,703
  • 8
  • 98
  • 85