stripping html of tags

4 views
Skip to first unread message

a

unread,
Sep 12, 2006, 6:33:31 AM9/12/06
to Django users
hi guys
i want to display a snippet of data from a html source, and i want to
strip it of html because an unclose tag will make the rest of the page
look like
that
please help me out
thanks

Guillermo Fernandez Castellanos

unread,
Sep 12, 2006, 7:07:45 AM9/12/06
to django...@googlegroups.com
Cheers,

> i want to display a snippet of data from a html source, and i want to
> strip it of html because an unclose tag will make the rest of the page
> look like

You have the striptags tag:
http://www.djangoproject.com/documentation/templates/#striptags

You can also access the function from outside the templates. It is in:
django/utils/html.py:

def strip_tags(value):
"Returns the given HTML with all tags stripped"
return re.sub(r'<[^>]*?>', '', value)

Hope it helps,

G

a

unread,
Sep 12, 2006, 6:13:08 PM9/12/06
to Django users
url a gem
wat about unclosed tags
such a href="google.com
because
i need a slice of data...

a

unread,
Sep 12, 2006, 8:40:51 PM9/12/06
to Django users
<a href="http://youtube.com/profile?us
leaves these behind
do you know to fix these

SmileyChris

unread,
Sep 12, 2006, 9:14:56 PM9/12/06
to Django users
Why don't you strip before you slice.

a

unread,
Sep 13, 2006, 2:40:26 AM9/13/06
to Django users
because i have to display about 10 elements and each can be over 1 or
2pages long
but i m going to display only 200 characters from each and if i strip
the whole thing it becomes a huge time lag for generating the page..

SmileyChris

unread,
Sep 13, 2006, 6:00:55 PM9/13/06
to Django users
How about slicing to 1000 (or however much you want to be safe that
you'll get 200 of non-tags), then strip, then slice down to 200.

For a slightly different approach there is a patch I wrote for
providing an html-aware truncatewords filter at
http://code.djangoproject.com/ticket/2027 which you could try using.

a

unread,
Sep 14, 2006, 5:16:29 AM9/14/06
to Django users
i dont understand patches
i ll appreciate if you can send me the html file
thanks

v...@klankschap.nl

unread,
Sep 14, 2006, 5:26:33 AM9/14/06
to django...@googlegroups.com
As i'm still rather new to this django stuff, here is my simple question:
Is it possible to install django on an alien server?
Alien in the meaning of having it hosted by a provider.
Similar to having mambo or phpbbs or what have you in php flavored
systems.

thanks!
Floris van Manen


Kenneth Gonsalves

unread,
Sep 14, 2006, 6:15:38 AM9/14/06
to django...@googlegroups.com

On 14-Sep-06, at 2:56 PM, v...@klankschap.nl wrote:

> As i'm still rather new to this django stuff, here is my simple
> question:
> Is it possible to install django on an alien server?

as long as you have shell access you can do so

--

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/


Frankie Robertson

unread,
Sep 14, 2006, 1:51:34 PM9/14/06
to django...@googlegroups.com
On 14/09/06, Kenneth Gonsalves <law...@thenilgiris.com> wrote:
>
>
> On 14-Sep-06, at 2:56 PM, v...@klankschap.nl wrote:
>
> > As i'm still rather new to this django stuff, here is my simple
> > question:
> > Is it possible to install django on an alien server?
>
> as long as you have shell access you can do so

That's generally a good rule of the thumb. However there are some
hosts that have shell access but not fastcgi or mod_python and there
could be hosts (although I know of none currently) that have fastcgi
and python but no shell access.

Frankie

Reply all
Reply to author
Forward
0 new messages