Re: Accessing a python function from a blog post stored in the db?

2014-02-28 Thread C. Kirby
Broadly speaking, yes. The details may get hairy, but those are probably 
better dealt with in issue specific threads.

Good luck, and don't hesitate to bring up any other questions.

~CK

On Thursday, February 27, 2014 5:29:34 PM UTC-6, Dennis Marwood wrote:
>
> OK I think you are talking about something like 
> https://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related-objectswhere
>  I could just insert a slider type of entry and then a text entry and 
> so on. Is that it?
>
> On Wednesday, 26 February 2014 14:49:55 UTC-8, C. Kirby wrote:
>>
>> It doesn't have to, I guess it depends on how involved the creation tools 
>> are that you create. Quick and dirty idea off the top of my head:
>> If the authoring tools define post widgets (body, text, scroller, video, 
>> etc) you could let authors drag and drop the elements as they wish. On the 
>> model side, make all resources extend a base class of BlogResource type, 
>> then for each blog post have a many to many through table that stores 
>> ordering:
>> PostID(foriegn=blog)
>> ResourceID(genericforeignkey to blog resource)
>> OrderID(int)
>>
>> or somthing like that.
>>
>> Regards,
>> ~CK
>>
>> On Wednesday, February 26, 2014 4:18:14 PM UTC-6, Dennis Marwood wrote:
>>>
>>> Won't this force my blog posts to all be the same. i.e. Text then a 
>>> image scroller? 
>>> How would I handle the case where a blog post was Text, image scroller, 
>>> text, image scroller?
>>>
>>> On Wednesday, 26 February 2014 13:35:01 UTC-8, C. Kirby wrote:

 It sounds like your implementation is a little skewed.
 If a blog post is made of multiple resources (summary, body, multiple 
 image collections, etc.) You should probably have a model or models with 
 the appropriate fields/relationships.  That way your template can house 
 all 
 of the template language, and you build a single, user facing blog post 
 from the elements in the blog post model(s).
 This also gives you the benefit of making the various resources 
 available in other ways (eg. Show all my image collections, share 
 collections, etc) as well as change your layout in the future without 
 having hard-coded template calls in your content.

 Regards
 ~CK

 On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:
>
> Thanks. I look forward to trying this soon.
>
> I feel like I may be trying to swim against the current with this. Is 
> this a problem with the way that I have decided to implement my blog or 
> are 
> these workarounds typical for django applications?
>
> On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
>>
>> On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood  
>> wrote: 
>> > 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 %} 
>> > {{ each.entry }} 
>> > {% 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? 
>>
>> Yes. You will need to write a custom template tag to parse the 
>> contents of the object as a template, render it within the current 
>> context and return the generated data. 
>>
>> Writing a custom template tag: 
>>
>>
>> https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags
>>  
>>
>> Rendering templates to string: 
>>
>>
>> https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context
>>  
>>
>> Your content.html would then look something like this, assuming you 
>> called the custom tag 'render': 
>>
>> {% for each in entries %} 
>> {% render each.entry %} 
>> {% endfor %} 
>>
>> Beware the massive security holes if you allow users to generate 
>> content that your site then renders as a template. 
>>
>> Cheers 
>>
>> Tom 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" g

Re: Accessing a python function from a blog post stored in the db?

2014-02-27 Thread Dennis Marwood
OK I think you are talking about something like 
https://docs.djangoproject.com/en/dev/intro/tutorial02/#adding-related-objects 
where I could just insert a slider type of entry and then a text entry and 
so on. Is that it?

On Wednesday, 26 February 2014 14:49:55 UTC-8, C. Kirby wrote:
>
> It doesn't have to, I guess it depends on how involved the creation tools 
> are that you create. Quick and dirty idea off the top of my head:
> If the authoring tools define post widgets (body, text, scroller, video, 
> etc) you could let authors drag and drop the elements as they wish. On the 
> model side, make all resources extend a base class of BlogResource type, 
> then for each blog post have a many to many through table that stores 
> ordering:
> PostID(foriegn=blog)
> ResourceID(genericforeignkey to blog resource)
> OrderID(int)
>
> or somthing like that.
>
> Regards,
> ~CK
>
> On Wednesday, February 26, 2014 4:18:14 PM UTC-6, Dennis Marwood wrote:
>>
>> Won't this force my blog posts to all be the same. i.e. Text then a image 
>> scroller? 
>> How would I handle the case where a blog post was Text, image scroller, 
>> text, image scroller?
>>
>> On Wednesday, 26 February 2014 13:35:01 UTC-8, C. Kirby wrote:
>>>
>>> It sounds like your implementation is a little skewed.
>>> If a blog post is made of multiple resources (summary, body, multiple 
>>> image collections, etc.) You should probably have a model or models with 
>>> the appropriate fields/relationships.  That way your template can house all 
>>> of the template language, and you build a single, user facing blog post 
>>> from the elements in the blog post model(s).
>>> This also gives you the benefit of making the various resources 
>>> available in other ways (eg. Show all my image collections, share 
>>> collections, etc) as well as change your layout in the future without 
>>> having hard-coded template calls in your content.
>>>
>>> Regards
>>> ~CK
>>>
>>> On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:

 Thanks. I look forward to trying this soon.

 I feel like I may be trying to swim against the current with this. Is 
 this a problem with the way that I have decided to implement my blog or 
 are 
 these workarounds typical for django applications?

 On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
>
> On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood  
> wrote: 
> > 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 %} 
> > {{ each.entry }} 
> > {% 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? 
>
> Yes. You will need to write a custom template tag to parse the 
> contents of the object as a template, render it within the current 
> context and return the generated data. 
>
> Writing a custom template tag: 
>
>
> https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags
>  
>
> Rendering templates to string: 
>
>
> https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context
>  
>
> Your content.html would then look something like this, assuming you 
> called the custom tag 'render': 
>
> {% for each in entries %} 
> {% render each.entry %} 
> {% endfor %} 
>
> Beware the massive security holes if you allow users to generate 
> content that your site then renders as a template. 
>
> Cheers 
>
> Tom 
>


-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/c2f6e17b-08eb-4aa5-8cb5-bee4169016ea%40googlegro

Re: Accessing a python function from a blog post stored in the db?

2014-02-26 Thread C. Kirby
It doesn't have to, I guess it depends on how involved the creation tools 
are that you create. Quick and dirty idea off the top of my head:
If the authoring tools define post widgets (body, text, scroller, video, 
etc) you could let authors drag and drop the elements as they wish. On the 
model side, make all resources extend a base class of BlogResource type, 
then for each blog post have a many to many through table that stores 
ordering:
PostID(foriegn=blog)
ResourceID(genericforeignkey to blog resource)
OrderID(int)

or somthing like that.

Regards,
~CK

On Wednesday, February 26, 2014 4:18:14 PM UTC-6, Dennis Marwood wrote:
>
> Won't this force my blog posts to all be the same. i.e. Text then a image 
> scroller? 
> How would I handle the case where a blog post was Text, image scroller, 
> text, image scroller?
>
> On Wednesday, 26 February 2014 13:35:01 UTC-8, C. Kirby wrote:
>>
>> It sounds like your implementation is a little skewed.
>> If a blog post is made of multiple resources (summary, body, multiple 
>> image collections, etc.) You should probably have a model or models with 
>> the appropriate fields/relationships.  That way your template can house all 
>> of the template language, and you build a single, user facing blog post 
>> from the elements in the blog post model(s).
>> This also gives you the benefit of making the various resources available 
>> in other ways (eg. Show all my image collections, share collections, etc) 
>> as well as change your layout in the future without having hard-coded 
>> template calls in your content.
>>
>> Regards
>> ~CK
>>
>> On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:
>>>
>>> Thanks. I look forward to trying this soon.
>>>
>>> I feel like I may be trying to swim against the current with this. Is 
>>> this a problem with the way that I have decided to implement my blog or are 
>>> these workarounds typical for django applications?
>>>
>>> On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:

 On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood  
 wrote: 
 > 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 %} 
 > {{ each.entry }} 
 > {% 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? 

 Yes. You will need to write a custom template tag to parse the 
 contents of the object as a template, render it within the current 
 context and return the generated data. 

 Writing a custom template tag: 


 https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags
  

 Rendering templates to string: 


 https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context
  

 Your content.html would then look something like this, assuming you 
 called the custom tag 'render': 

 {% for each in entries %} 
 {% render each.entry %} 
 {% endfor %} 

 Beware the massive security holes if you allow users to generate 
 content that your site then renders as a template. 

 Cheers 

 Tom 

>>>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/cd721dcb-5dd8-40d7-8df9-c7ef74057ecf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing a python function from a blog post stored in the db?

2014-02-26 Thread Dennis Marwood
Won't this force my blog posts to all be the same. i.e. Text then a image 
scroller? 
How would I handle the case where a blog post was Text, image scroller, 
text, image scroller?

On Wednesday, 26 February 2014 13:35:01 UTC-8, C. Kirby wrote:
>
> It sounds like your implementation is a little skewed.
> If a blog post is made of multiple resources (summary, body, multiple 
> image collections, etc.) You should probably have a model or models with 
> the appropriate fields/relationships.  That way your template can house all 
> of the template language, and you build a single, user facing blog post 
> from the elements in the blog post model(s).
> This also gives you the benefit of making the various resources available 
> in other ways (eg. Show all my image collections, share collections, etc) 
> as well as change your layout in the future without having hard-coded 
> template calls in your content.
>
> Regards
> ~CK
>
> On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:
>>
>> Thanks. I look forward to trying this soon.
>>
>> I feel like I may be trying to swim against the current with this. Is 
>> this a problem with the way that I have decided to implement my blog or are 
>> these workarounds typical for django applications?
>>
>> On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
>>>
>>> On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood  
>>> wrote: 
>>> > 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 %} 
>>> > {{ each.entry }} 
>>> > {% 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? 
>>>
>>> Yes. You will need to write a custom template tag to parse the 
>>> contents of the object as a template, render it within the current 
>>> context and return the generated data. 
>>>
>>> Writing a custom template tag: 
>>>
>>>
>>> https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags
>>>  
>>>
>>> Rendering templates to string: 
>>>
>>>
>>> https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context
>>>  
>>>
>>> Your content.html would then look something like this, assuming you 
>>> called the custom tag 'render': 
>>>
>>> {% for each in entries %} 
>>> {% render each.entry %} 
>>> {% endfor %} 
>>>
>>> Beware the massive security holes if you allow users to generate 
>>> content that your site then renders as a template. 
>>>
>>> Cheers 
>>>
>>> Tom 
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/a010cac7-55c9-4d53-bb58-086e0b832c48%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing a python function from a blog post stored in the db?

2014-02-26 Thread C. Kirby
It sounds like your implementation is a little skewed.
If a blog post is made of multiple resources (summary, body, multiple image 
collections, etc.) You should probably have a model or models with the 
appropriate fields/relationships.  That way your template can house all of 
the template language, and you build a single, user facing blog post from 
the elements in the blog post model(s).
This also gives you the benefit of making the various resources available 
in other ways (eg. Show all my image collections, share collections, etc) 
as well as change your layout in the future without having hard-coded 
template calls in your content.

Regards
~CK

On Wednesday, February 26, 2014 3:18:54 PM UTC-6, Dennis Marwood wrote:
>
> Thanks. I look forward to trying this soon.
>
> I feel like I may be trying to swim against the current with this. Is this 
> a problem with the way that I have decided to implement my blog or are 
> these workarounds typical for django applications?
>
> On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
>>
>> On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood  
>> wrote: 
>> > 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 %} 
>> > {{ each.entry }} 
>> > {% 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? 
>>
>> Yes. You will need to write a custom template tag to parse the 
>> contents of the object as a template, render it within the current 
>> context and return the generated data. 
>>
>> Writing a custom template tag: 
>>
>>
>> https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags
>>  
>>
>> Rendering templates to string: 
>>
>>
>> https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context 
>>
>> Your content.html would then look something like this, assuming you 
>> called the custom tag 'render': 
>>
>> {% for each in entries %} 
>> {% render each.entry %} 
>> {% endfor %} 
>>
>> Beware the massive security holes if you allow users to generate 
>> content that your site then renders as a template. 
>>
>> Cheers 
>>
>> Tom 
>>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/ad4f77f1-a18a-4472-9a0c-57792588f2be%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing a python function from a blog post stored in the db?

2014-02-26 Thread Dennis Marwood
Thanks. I look forward to trying this soon.

I feel like I may be trying to swim against the current with this. Is this 
a problem with the way that I have decided to implement my blog or are 
these workarounds typical for django applications?

On Wednesday, 26 February 2014 04:15:15 UTC-8, Tom Evans wrote:
>
> On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood 
> > 
> wrote: 
> > 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 %} 
> > {{ each.entry }} 
> > {% 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? 
>
> Yes. You will need to write a custom template tag to parse the 
> contents of the object as a template, render it within the current 
> context and return the generated data. 
>
> Writing a custom template tag: 
>
>
> https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags
>  
>
> Rendering templates to string: 
>
>
> https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context 
>
> Your content.html would then look something like this, assuming you 
> called the custom tag 'render': 
>
> {% for each in entries %} 
> {% render each.entry %} 
> {% endfor %} 
>
> Beware the massive security holes if you allow users to generate 
> content that your site then renders as a template. 
>
> Cheers 
>
> Tom 
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/84d40bec-8dfb-4b6d-99e3-9e908fa6fbfc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing a python function from a blog post stored in the db?

2014-02-26 Thread Tom Evans
On Wed, Feb 26, 2014 at 5:29 AM, Dennis Marwood  wrote:
> 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 %}
> {{ each.entry }}
> {% 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?

Yes. You will need to write a custom template tag to parse the
contents of the object as a template, render it within the current
context and return the generated data.

Writing a custom template tag:

https://docs.djangoproject.com/en/1.6/howto/custom-template-tags/#writing-custom-template-tags

Rendering templates to string:

https://docs.djangoproject.com/en/1.6/ref/templates/api/#rendering-a-context

Your content.html would then look something like this, assuming you
called the custom tag 'render':

{% for each in entries %}
{% render each.entry %}
{% endfor %}

Beware the massive security holes if you allow users to generate
content that your site then renders as a template.

Cheers

Tom

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAFHbX1%2BkDdaL5UqY_npcVfnPsZNisffOhzme-C768tC%3DnAycMA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing a python function from a blog post stored in the db?

2014-02-25 Thread Dennis Marwood
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 %}
{{ each.entry }}
{% 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 
> 
> > 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 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/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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/b057db2a-2930-455d-94b3-1c9e6741ed91%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Accessing a python function from a blog post stored in the db?

2014-02-25 Thread Jonathan Baker
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 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAPMFOb6iPJvUWGeLWkogmx5Bj4X22aNz8bN6pHSKqXm7hN-gyw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Accessing a python function from a blog post stored in the db?

2014-02-25 Thread Dennis Marwood
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/d38e2a00-5ae9-4e8e-8333-0677cc206a5e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.