I have followed the instructions on the following site in order to render a placeholder field from a model, but I didn't manage.
http://docs.django-cms.org/en/release-3.4.x/how_to/placeholders.html
This is my model.
from django.db import models
import uuid
from django.utils import timezone
from cms.models.fields import PlaceholderField
class HomePage(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, unique=True)
my_placeholder = PlaceholderField('placeholder_name')
modified_date = models.DateTimeField(default=timezone.now)
class Meta:
db_table = "home_page_content"
verbose_name = 'Home Page Content'
verbose_name_plural = 'Home Page Content'
This is my view.
from django.shortcuts import render
from app.models.home_page import HomePage
def HomePageContent(request):
object = HomePage.objects.all()
return render(request, 'home.html', {'object': object})
This is how I render the placeholder in the template.
{% load cms_tags %}
{% for obj in object %}
{% render_placeholder obj.my_placeholder "640" %}
{% endfor %}
And nothing shows up.
What am I missing? Any help would be much appreciated!