Textarea taking htnml tags

32 views
Skip to first unread message

akash...@ranosys.com

unread,
Mar 27, 2015, 2:27:15 AM3/27/15
to django...@googlegroups.com
Hie to all,
In one of my template i am using text area. The issue is that when i write html tags with some image link using img tag, when i am saving this i am getting image on the desription field.

Actual-Image is comming

Expected-I want HTML code to be displayed in the discription.

Please suggest

Filipe Ximenes

unread,
Mar 27, 2015, 10:56:00 AM3/27/15
to django...@googlegroups.com
Can you send us the code of the view and the template of this form?

--
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/32bb3e0a-1eb1-46d1-94fe-4135c7c916df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
  
Filipe Ximenes
+55 (81) 8245-9204
Vinta Software Studio
http://www.vinta.com.br

Gabriel - Iulian Dumbrava

unread,
Mar 27, 2015, 11:25:27 AM3/27/15
to django...@googlegroups.com
Have you checked if the html tags actually end up in the database?

If yes, then the problem is either in the view or in the template (like not using the safe filter).

aRkadeFR

unread,
Mar 27, 2015, 2:00:34 PM3/27/15
to django...@googlegroups.com
Hey,

He doubled post. A thread already exists about this called:
"textarea showing image instead of code"

Akash Patni

unread,
Mar 29, 2015, 11:41:26 PM3/29/15
to django...@googlegroups.com
Hi,
This my template
{% block content %}

<!-- Begin Body Columns -->

  <div class="container-top">
        <div class="container-top-icon"><img src="/site_media/images/digital-assets-note-icon.png" alt="Notes" /></div>
        <h2>View Notes</h2>
        <div class="container-top-detail">See your notes details.</div>
  </div>
  <div class="clear"></div>

    {% for i in result %}
<div class="da_row">
   <div class="da_label">Note Title</div>
   <div class="da_description">{{i.note_title}}</div>
</div>
<div class="clear"></div>
<div class="da_row">
   <div class="da_label">Note</div>
   <div class="da_description">{{i.note}}</div>
 
</div>
<div class="clear"></div>

<div class="da_row">
   <div class="da_label">Beneficiaries</div>
   <div class="da_description">
   {% if all_nominees %}
   {% for nominee in all_nominees %}
   {% if nominee.1 %}
   {{nominee.0.first_name}} {% if nominee.last_name %}{{nominee.last_name}}{% endif %} {% if nominee.0.is_charity %}(charity){% else %}(individual){% endif %}
   <br />
   {% endif %}
   {% endfor %}
{% else %}
<div>No beneficiaries at the moment.</div>
{% endif %}
   </div>
</div>
<div class="clear"></div>

<div class="da_row">
   <div class="da_label">Action</div>
   <div class="da_description">
       <div class="dashboard-options edit-btn"><a title="Edit" href="/user/notes/edit?id={{i.key}}">Edit</a></div>
       <div class="dashboard-options edit-btn"><a title="Delete" href="/user/notes/delete?id={{i.key}}" onclick="return deleteConfirmation();">Delete</a></div>
   </div>
</div>
<div class="clear"></div>
  {% endfor %}

{% endblock %}


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/cpx4qG6daPU/unsubscribe.
To unsubscribe from this group and all its topics, 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.

For more options, visit https://groups.google.com/d/optout.



--
Best Regards,
Akash Patni
Software Engineer

ranosys
  facebooktwitterlinkedingoogleplus 

Head Office: 
Oxley Bizhub, #06-48 | 73 Ubi Road 1 | Singapore - 408733
Tel: +65 66331556  |  HP: +65 98573420

Global Offices:
San Francisco, USA | Jaipur, India | Bikaner, India


Akash Patni

unread,
Mar 30, 2015, 7:29:34 AM3/30/15
to django...@googlegroups.com
hi
for removing html tags i have used the following function but it is not working...Please suggest

class NotesForm(forms.Form):
    ''' Notes '''
    note_title=forms.CharField(label="Note Title *:",max_length=100)
    note=forms.CharField(widget=forms.Textarea,label="Note:",required=False)
    def clean(self):
        from django.utils.html import strip_tags
        cleaned_data = super(NotesForm, self).clean()
        cleaned_data['note'] = strip_tags(cleaned_data.get('note'))
        return cleaned_data

and this is my html

 <form action="/user/notes/add" method="POST" id="notes" name="notes" method="post" class="fix-height checkbox_asset">
    <!--{{ form.as_p }}-->
      {% for field in form %}
      {%if field.name == 'note' %}
      <p>
      {{ field.label_tag }}
      {{ field}}
      </p>
      {% else %}
          <p>
          {{ field.label_tag }}{{ field }}
           {% for error in field.errors %}
           <label class="error">{{ error }}</label>
           {% endfor %}
           </p>
       {% endif %}
        {% endfor %}


I had also used striptag filter and this is also not working...
Reply all
Reply to author
Forward
0 new messages