Re: Print html the normal way

2012-10-05 Thread Ashish Jain
Hi,

Thanks a ton!!

using mark_safe() worked perfectly.

- Regards
Ashish

On Friday, 5 October 2012 14:10:31 UTC+5:30, Tom Evans wrote:
>
> On Fri, Oct 5, 2012 at 9:20 AM, Ashish Jain 
> > 
> wrote: 
> > Hi, 
> > 
> > I wrote a simple filter as: 
> > 
> > @register.filter() 
> > def html(value): 
> > return 'Check' 
> > 
> > when I use this filter in my template, it displays html as: 
> > 
> > Check 
> > 
> > I want to display as: 
> > 
> > Check 
> > 
> > am I missing something. 
> > 
>
> You haven't marked the output as safe, so Django escapes it: 
>
>
> https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/#filters-and-auto-escaping
>  
>
> You want option 2. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Sz5auuOkyYcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Print html the normal way

2012-10-05 Thread Ashish Jain
Hi, 

I wrote a simple filter as: 

@register.filter() 
def html(value): 
return 'Check' 

when I use this filter in my template, it displays html as: 

Check 

I want to display as: 

Check 

am I missing something. 

- Thanks for your help 
Ashish 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/gtEV05dOMWoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Add your own template library

2012-10-02 Thread Ashish Jain
And in settings.py, I have:

TEMPLATE_TAGS = ( 

  'templatemyweb.tags.repeat',

)


with which I am using this code snippet, *
http://djangosnippets.org/snippets/342/*

*
<http://djangosnippets.org/snippets/342/>*
- Regards
Ashish

On Monday, 1 October 2012 18:01:48 UTC+5:30, Javier Guerra wrote:
>
> On Sun, Sep 30, 2012 at 11:59 PM, Ashish Jain 
> > 
> wrote: 
> > After which I am referring it into my website. 
>
> ... and on settings.py? 
>
> -- 
> Javier 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XvRHRfXOKzMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Add your own template library

2012-10-01 Thread Ashish Jain

Thanks for the reply. Got the code working.
It was my mistake the way I was using template in my html page.

I had html page as: 

  {%load repeat%}
  ..
  {% repeat data %} {% endrepeat %}

I was not required to add  "*{%load repeat%}*" line, which was resulting 
into error. Straightway the repeat can be used.

- Thanks

On Monday, 1 October 2012 14:13:28 UTC+5:30, Tom Evans wrote:
>
> On Mon, Oct 1, 2012 at 5:59 AM, Ashish Jain 
> > 
> wrote: 
> > Hi, 
> > 
> > Yes it do have __init__.py 
> > 
> > I have created a simple project of template tags and have installed it 
> as a 
> > python package with setup.py. 
> > 
> > After which I am referring it into my website. 
> > 
> > - Thanks for reply 
> > 
>
> You can only load template libraries from apps. Is your template 
> library contained within an app listed in INSTALLED_APPS? 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/u1ibfrtyIlsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Add your own template library

2012-10-01 Thread Ashish Jain

For reference, I have manage.py as:

*#!/usr/bin/env python* 

*import os*

*import sys*

*
*

*# http://djangosnippets.org/snippets/342/*

*def load_templatetags():*

*  from django.conf import settings*

*  from django.template import add_to_builtins*

*
*

*  try:*

*   for lib in settings.TEMPLATE_TAGS:*

* print 'loading template tag %s'% lib*

* add_to_builtins(lib)*

*   print django.template.builtins[3].tags*

*   t = django.template.Template('{% load repeat %}')*

*   print t*

*  except AttributeError:*

*  pass*

*
*

*if __name__ == "__main__":*

*  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings")*

 *  from django.core.management import execute_from_command_line*

*
*

*  execute_from_command_line(sys.argv)*

*
*

*  load_templatetags()*


In the print statements, I get the third loaded library has tags 'repeat'
but, 
   t = django.template.Template('{% load repeat %}')
throws the same error.

- Regards
Ashish

On Monday, 1 October 2012 10:29:44 UTC+5:30, Ashish Jain wrote:
>
> Hi,
>
> Yes it do have __init__.py
>
> I have created a simple project of template tags and have installed it as 
> a python package with setup.py.
>
> After which I am referring it into my website.
>
> - Thanks for reply
>
> On Monday, 1 October 2012 09:45:46 UTC+5:30, Laxmikant Gurnalkar wrote:
>>
>> Hi Ashish, 
>> Is there __init__.py in your templatetags directory ? 
>>
>> cheers
>> *Laxmikant*
>>
>>
>> On Mon, Oct 1, 2012 at 9:36 AM, Ashish Jain  wrote:
>>
>>> Hi,
>>>
>>> I have created a custom template tags library which I would like to use 
>>> across my application.
>>> I referred this code snippet, http://djangosnippets.org/snippets/342/
>>>
>>> but still when I refer the tag in my code as: {% load repeat %}.
>>>
>>> It says 'repeat' is not a valid tag library, tried 
>>> django.templatetags.repeat,django.contrib.staticfiles.templatetags.repeat
>>>
>>> Any help would be appreciated.
>>>
>>> - Thanks
>>> Ashish
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/4AqRRolTYK0J.
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>>
>> -- 
>> * 
>>
>>  GlxGuru
>>
>> *
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/KowjfHjD4PoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Add your own template library

2012-09-30 Thread Ashish Jain
Hi,

Yes it do have __init__.py

I have created a simple project of template tags and have installed it as a 
python package with setup.py.

After which I am referring it into my website.

- Thanks for reply

On Monday, 1 October 2012 09:45:46 UTC+5:30, Laxmikant Gurnalkar wrote:
>
> Hi Ashish, 
> Is there __init__.py in your templatetags directory ? 
>
> cheers
> *Laxmikant*
>
>
> On Mon, Oct 1, 2012 at 9:36 AM, Ashish Jain 
> > wrote:
>
>> Hi,
>>
>> I have created a custom template tags library which I would like to use 
>> across my application.
>> I referred this code snippet, http://djangosnippets.org/snippets/342/
>>
>> but still when I refer the tag in my code as: {% load repeat %}.
>>
>> It says 'repeat' is not a valid tag library, tried 
>> django.templatetags.repeat,django.contrib.staticfiles.templatetags.repeat
>>
>> Any help would be appreciated.
>>
>> - Thanks
>> Ashish
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/4AqRRolTYK0J.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> * 
>
>  GlxGuru
>
> *
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/I1f8NTaWQM4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Add your own template library

2012-09-30 Thread Ashish Jain
Hi,

I have created a custom template tags library which I would like to use 
across my application.
I referred this code snippet, http://djangosnippets.org/snippets/342/

but still when I refer the tag in my code as: {% load repeat %}.

It says 'repeat' is not a valid tag library, tried 
django.templatetags.repeat,django.contrib.staticfiles.templatetags.repeat

Any help would be appreciated.

- Thanks
Ashish

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4AqRRolTYK0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.