How to print html in python the normal way

A

ashishjain.ash

Hi,

I wrote a simple filter as:

@register.filter()
def html(value):
return '<p>Check</p>'

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

<p>Check</p>

I want to display as:

Check

am I missing something.

- Thanks for your help
Ashish
 
C

Chris Angelico

am I missing something.

The first thing you're missing is more detail in your question. My
crystal ball tells me you're using some kind of web framework and
viewing this in your browser. And my second crystal ball suggests that
it's probably Django. But is this correct? Lots more detail, please!

ChrisA
 
R

Ramchandra Apte

The first thing you're missing is more detail in your question. My

crystal ball tells me you're using some kind of web framework and

viewing this in your browser. And my second crystal ball suggests that

it's probably Django. But is this correct? Lots more detail, please!



ChrisA

+1
 
R

Ramchandra Apte

The first thing you're missing is more detail in your question. My

crystal ball tells me you're using some kind of web framework and

viewing this in your browser. And my second crystal ball suggests that

it's probably Django. But is this correct? Lots more detail, please!



ChrisA

+1
 
J

Joel Goldstick

You should look at the built in django tags, and learn about them
before writing your own

In this case, look here:
https://docs.djangoproject.com/en/dev/topics/templates/#filters


striptags

Strips all [X]HTML tags. For example:

{{ value|striptags }}

If value is "<b>Joel</b> <button>is</button> a <span>slug</span>",
the output will be "Joel is a slug".

Again, these are just a few examples; see the built-in filter
reference for the complete list.
 
A

ashishjain.ash

Hi,

Thanks for the reply.
Apologies for my question not clear. Yes I am using django framework for it.

- Regards
Ashish
 
A

ashishjain.ash

Hi,

Thanks for the reply.
Apologies for my question not clear. Yes I am using django framework for it.

- Regards
Ashish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top