Textarea taking htnml tags

閲覧: 32 回
最初の未読メッセージにスキップ

akash...@ranosys.com

未読、
2015/03/27 2:27:152015/03/27
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

未読、
2015/03/27 10:56:002015/03/27
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

未読、
2015/03/27 11:25:272015/03/27
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

未読、
2015/03/27 14:00:342015/03/27
To: django...@googlegroups.com
Hey,

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

Akash Patni

未読、
2015/03/29 23:41:262015/03/29
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

未読、
2015/03/30 7:29:342015/03/30
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...
全員に返信
投稿者に返信
転送
新着メール 0 件