LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-11-2013, 08:57 PM   #1
stateless
Member
 
Registered: Jan 2013
Distribution: Debian
Posts: 166
Blog Entries: 1

Rep: Reputation: 4
django: HTML escaping inside a function


In django: If you need to do some HTML escaping inside of a function (not afterwards in the template) does django have a function for that? Can't seem to find it through the danjo documentation search.
 
Old 10-12-2013, 07:55 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
By HTML escaping, do you mean replacing special characters with HTML entities? You can do that with cgi.escape():

Code:
>>> import cgi
>>> print cgi.escape('<p>Hello, World!</p>')
&lt;p&gt;Hello, World!&lt;/p&gt;
 
Old 10-12-2013, 01:20 PM   #3
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,222

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
django.utils.html.escape
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can a function know its name, inside it? P5music Programming 2 01-04-2011 12:39 PM
[SOLVED] {} inside a function genderbender Programming 2 07-29-2010 09:58 AM
using PHP inside of HTML on a Slackware server, Bobcat3Romeo1 Linux - Software 15 06-18-2010 05:53 AM
function calls inside a function manas_sem Programming 2 02-28-2007 01:27 AM
function defn inside a function in C...!!! arunka Programming 1 02-05-2006 01:08 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration