Andrew,

I'm not sure, but since no one else has answered yet...

Maybe you can't pass an object as a keyword argument to include,
can only pass strings?  I've done it often with strings, but never
with an object.  Try:

    {% include "sidebar.html" title=object.title %}

and in the included file, use simply:

    {{title}}

It seems odd that there'd be a restriction like this since I'm sure
you can pass objects to templates from views, but it's worth
trying.  May be a good workaround, or may get you a different
error message that tips you off to what the real problem is.

--Fred
------------------------------------------------------------------------
Fred Stluka -- mailto:[email protected] -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.
------------------------------------------------------------------------
On 12/16/14 2:27 PM, Andrew Nguyen wrote:

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.html|and |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"  %}

<divclass="mainContent clearfix">
     <h1>{{object.title}}</h1>
     <pclass="date">{{object.pubDate|date:"l, F j, Y"  }}</p>  |  
<pclass="author">{{object.author}}</p>
     <img src="{{object.heroImage}}"  alt=""  class="largeImage">
     <divclass="contentBlock">
         <img src="{{object.relatedImage}}"  alt=""  class="relatedImage">

         <pclass="content">{{object.body|linebreaks}}</p>
     </div><!--  /.contentBlock-->

     <!--  This  grabs the slider snippet-->
     {%  include"slider.html"  %}

</div><!--  /.mainContent-->|

*slider.html*

|<divclass="slider">
             <divclass="group visible">
                 <divclass="sliderItem">
                     <a href="{%url"detailed" slug=article.slug %}"><img src="{{article.relatedImage}}"  
alt=""  class="sliderPicture"></a>
                     <a href="{%url"detailed" slug=article.slug 
%}"><pclass="related">{{article.title}}</p></a>
                 </div><!--  /.sliderItem-->
             </div><!--  /.group-->
     </div><!--  /.slider-->|

*sidebar.html*

|<divclass="navContent">
             {%  for  articlein  object_list|slice:":5"  %}
             <divclass="navItem">
                 <divclass="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 
%}"><pclass="navTitle">{{article.title|truncatewords:"4"}}</p></a>
             </div><!--  /.navItem-->
             {%  endfor%}
         </div><!--  /.navContent-->|

*models.py*

|from  django.dbimport  models
from  django.core.urlresolversimport  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.viewsimport  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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
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 <https://groups.google.com/d/msgid/django-users/343cde15-36ab-4432-836b-5947922e48b2%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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 [email protected].
To post to this group, send email to [email protected].
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/5491016F.7070903%40bristle.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to