Thanks. I believe this is what I am looking for. However I am still running
into an issue w/ the fact that I am pulling my blog entries from the db.
This is causing the template to interpret the {% image_slider %} as a
string.
>From view.py:
def blog(request):
entries =
Project.objects.filter(destination="blog").order_by('-creation_date')
return render(request, 'content.html', {"entries": entries,
"page_title": "Blog",
"description": "Blog"})
And in content.html:
{% for each in entries %}
<p>{{ each.entry }}</p>
{% endfor %}
And a blog entry:
Hello! Check out this collection of images. {% image_slider %} And this
collection! {% image_slider %}
I don't want to hard code the inclusion tag in the content.html. Instead I
want to call it from the blog post. Is this possible?
On Tuesday, 25 February 2014 05:52:33 UTC-8, jondbaker wrote:
>
> This sounds like a good fit for an inclusion tag. Since you need a bit of
> markup around the images for the slider functionality, it'd be nice to keep
> that markup in a separate template so you could use the image slider in
> multiple places like, say, a post detail page as well as a dashboard. Then,
> anytime you wanted to create image slider, in your template you could
> simply do something like:
>
> {% load image_extras %}
>
> ...
> {% image_slider post.image_set %}
> ...
>
> Docs:
> https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags
>
> JDB
>
>
> On Mon, Feb 24, 2014 at 11:39 PM, Dennis Marwood
> <[email protected]<javascript:>
> > wrote:
>
>> Hi. I am looking for some advice on the best way to approach the
>> following:
>>
>> I am pulling my blog posts out of my db. Inside of the posts I want to
>> use an image scroller ( http://cssdeck.com/labs/css3-image-slider ), but
>> I don't want to write all of the boilerplate surrounding each image every
>> time.
>>
>> The idea I have is a template filter.... but that just seems wrong.
>> What's the proper way to handle this?
>>
>> Ideally, I would just add some bit in my post like css_slider({loc:
>> loc_pic_1, desc: "blah blah"}, {loc: loc_pic_1, desc: "blah"}...)
>>
>> --
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> 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/d38e2a00-5ae9-4e8e-8333-0677cc206a5e%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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/b057db2a-2930-455d-94b3-1c9e6741ed91%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.