I'm having some problems getting some of my content to appear on my detailed page view, which I have in two separate html files that are being pulled in using {% include %}. Inside my two files, slider.htmland sidebar.html, I'm using tags like {{article.title}} to grab specific information I need about an article.
TRIED:
- Changing syntax in the two included files to {{object.title}} did not work.
- I've tried doing {% include "sidebar.html" article=object %} in my detailed.html and it did not work. Instead, I would get an error TemplateSyntaxError at /gone-home Unknown argument for u'include' tag: u'article=object'.
- Also tried doing `{% include "sidebar.html" with article=object %} did not work either.
detailed.html
<!-- This grabs the sidebar snippet -->
{% include "sidebar.html" %}
<div class="mainContent clearfix">
<h1>{{object.title}}</h1>
<p class="date">{{object.pubDate|date:"l, F j, Y" }}</p> | <p class="author">{{object.author}}</p>
<img src="{{object.heroImage}}" alt="" class="largeImage">
<div class="contentBlock">
<img src="{{object.relatedImage}}" alt="" class="relatedImage">
<p class="content">{{object.body|linebreaks}}</p>
</div><!-- /.contentBlock -->
<!-- This grabs the slider snippet -->
{% include "slider.html" %}
</div><!-- /.mainContent -->slider.html
<div class="slider">
<div class="group visible">
<div class="sliderItem">
<a href="{%url "detailed" slug=article.slug %}"><img src="{{article.relatedImage}}" alt="" class="sliderPicture"></a>
<a href="{%url "detailed" slug=article.slug %}"><p class="related">{{article.title}}</p></a>
</div><!-- /.sliderItem -->
</div><!-- /.group -->
</div><!-- /.slider -->sidebar.html
<div class="navContent">
{% for article in object_list|slice:":5" %}
<div class="navItem">
<div class="overlay">
</div><!-- /.overlay -->
<a href="{%url "detailed" slug=article.slug %}"><img src="{{article.relatedImage}}" alt="" class="navPicture"></a>
<a href="{%url "detailed" slug=article.slug %}"><p class="navTitle">{{article.title|truncatewords:"4"}}</p></a>
</div><!-- /.navItem -->
{% endfor %}
</div><!-- /.navContent -->models.py
from django.db import models
from django.core.urlresolvers import reverse
# Create your models here.
class FullArticleQuerySet(models.QuerySet):
def published(self):
return self.filter(publish=True)
class FullArticle(models.Model):
title = models.CharField(max_length=150)
author = models.CharField(max_length=150)
slug = models.SlugField(max_length=200, unique=True)
pubDate = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
category = models.CharField(max_length=150)
# gameRank = models.PositiveSmallIntegerField(default=0)
heroImage = models.CharField(max_length=250, blank=True)
relatedImage = models.CharField(max_length=250, blank=True)
body = models.TextField()
publish = models.BooleanField(default=True)
objects = FullArticleQuerySet.as_manager()
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse("FullArticle_detailed", kwargs={"slug": self.slug})
def random(self):
return self.get_queryset().order_by('?').values('title','author','heroImage','body').first()
class Meta:
verbose_name = "Blog entry"
verbose_name_plural = "Blog Entries"
ordering = ["-pubDate"]views.py
from django.views import generic
from . import models
# Create your views here.
class BlogIndex(generic.ListView):
queryset = models.FullArticle.objects.published()
template_name = "list.html"
# paginate_by = 2
class BlogDetail(generic.DetailView):
model = models.FullArticle
template_name = "detailed.html"I'm having some problems getting some of my content to appear on my detailed page view, which I have in two separate html files that are being pulled in using
{% include %}. Inside my two files,slider.htmlandsidebar.html, I'm using tags like{{article.title}}to grab specific information I need about an article.
TRIED:
- Changing syntax in the two included files to{{object.title}}did not work.- I've tried doing
{% include "sidebar.html" article=object %}in mydetailed.htmland it did not work. Instead, I would get an errorTemplateSyntaxError at /gone-home Unknown argument for u'include' tag: u'article=object'.- Also tried doing `{% include "sidebar.html" with article=object %} did not work either.
detailed.html
<!-- This grabs the sidebar snippet --> {% include "sidebar.html" %} <div class="mainContent clearfix"> <h1>{{object.title}}</h1> <p class="date">{{object.pubDate|date:"l, F j, Y" }}</p> | <p class="author">{{object.author}}</
p< /span>>
slug = models.SlugField(max_length=200, unique! =True)
pubDate = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) category = models.CharField(max_length=150) # gameRank = models.PositiveSmallIntegerField(default=0)
heroImage = models.CharField(max_length=250, b! lank=True) relatedImage = models.CharField(max_length=250, blank=True)
body = models.TextField() publish = models.BooleanField(default=True) objects = FullArticleQuerySet.as_manager() def __str__(self): return self.title def get_absolute_url(self): return reverse("FullArticle_detailed", kwargs={"slug": self.slug}) def random(self):
return self.get_queryset().order_by('?').valu! es< span class="pun" style="font-size: 13.6960000991821px; background: transparent;">('title','author','heroImage','body').first()
class Meta: verbose_name = "Blog entry" verbose_name_plural = "Blog Entries" ordering = ["-pubDate"]
views.py
from django.views import generic from . import models # Create your views here. class BlogIndex(generic.ListView): queryset = models.FullArticle.objects.published() template_name = "list.html" # paginate_by = 2 class BlogDetail(generic.DetailView): model = models.FullArticle template_name = "detailed.html"
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/343cde15-36ab-4432-836b-5947922e48b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'm having some problems getting some of my content to appear on my detailed page view, which I have in two separate html files that are being pulled in using
{% include %}. Inside my two files,slider.htmlandsidebar.html, I'm using tags like{{article.title}}to grab specific information I need about an article.