Monday, March 30, 2015

Re: Textarea taking htnml tags

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...

On Mon, Mar 30, 2015 at 9:11 AM, Akash Patni <akash.patni@ranosys.com> wrote:
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 %}


On Fri, Mar 27, 2015 at 11:30 PM, aRkadeFR <contact@arkade.info> wrote:
Hey,

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



On 03/27/2015 03:54 PM, Filipe Ximenes wrote:
Can you send us the code of the view and the template of this form?

On Fri, Mar 27, 2015 at 3:27 AM, <akash.patni@ranosys.com> wrote:
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
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CAA-QWB3OPdmK11XzPFf--2MBT6evTDu-RuRrPArem1PbZT2FmA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/55159AA1.9070605%40arkade.info.

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





--
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


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/CANSMZiRLL5P3nOXtYEG5%2BQ5yhgqkYuEkeVSDZLZz2ywzxdOzgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment