Monday, January 1, 2018

Re: Django: text, font, and style

I even tried putting this at the top of my detail template, inside {& block content %}:

    <style>

    p }

    color: red;
    }

    </style>

But the result was the same:

    <p>This is all just to help me understand. I put this</p>

So what am I doing wrong, here?

"None of you has faith until he loves for his brother or his neighbor what he loves for himself."

On Mon, Jan 1, 2018 at 2:47 PM, Malik Rumi <malik.a.rumi@gmail.com> wrote:
This also fails, and renders exactly as you now see it on my web page:

    {% autoescape off %}
    <h1 class="text-info">Yea, that's going to be a monster....</h1>
    {% endautoescape %}

"None of you has faith until he loves for his brother or his neighbor what he loves for himself."

On Mon, Jan 1, 2018 at 2:28 PM, Malik Rumi <malik.a.rumi@gmail.com> wrote:
Well, as I said at the beginning, I don't seem to 'get' autoescape and safe. For example, I put this in my template:

{{ object.content|linebreaks|safe }}

But the result in my web page is:

     <p>Friday, November 17, 2017<br>

     5:36 pm</p>

     <h3>pga4 and mezz</h3>

     <p>I am happy to report.....  

So what am i doing wrong here? (I didn't know I could use safe in a view. Haven't tried that yet.)


"None of you has faith until he loves for his brother or his neighbor what he loves for himself."

On Mon, Jan 1, 2018 at 1:32 PM, Jani Tiainen <redetin@gmail.com> wrote:
Hi.

By default all strings processed through Django templating language are considered as unsafe. IOW all strings gets HTML escaped properly.

To get around that you can either use safe filter or declare particular string as a safe in a view.

1.1.2018 20.47 "Malik Rumi" <malik.a.rumi@gmail.com> kirjoitti:

Apparently I completely misunderstand the built in template tags {% autoescape &} and {% safe %}. Either they don't do what I expect, or I can't get them to do what I expect. But what I am trying to do is not at all unusual, so this post is all about learning from the community what are the best practices for getting this done.


Simply put, I want to be able to put some style on any arbitrary text in any arbitrary article on my site.


I have tried the version of TinyMCE built into Mezzanine. I found it both too limiting and too complex for my purposes. I also think the idea of using a wysiwg editor just to make a single word <b>bold</b> or with <font: color=yellow> highlighting is pretty heavy handed. There must be a better way. What is it?


I did stumble across a snippet for a custom template tag, https://www.djangosnippets.org/snippets/1242/, but it is 9 years old and has only one comment in all that time. Although the comment is favorable, that's hardly what I would call a large and happy current user base. On the flip side, I assume this is not very different from how {% url %} works, so maybe it can be hacked to do what I'm talking about?


I also looked at djangopackages, and the results were disappointing. Django-text looked promising, but the author wrote me that it is no longer in active development :-(


So, all you experts out there, how do you solve this problem? Thanks.


p.s. I am comfortable with html, but CSS and javascript, not so much. Doesn't mean I can't or won't learn if that's your go to option, I'm just letting you know where I am.


p.s.s. HAPPY NEW YEAR TO ALL!

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0b700a53-7812-4a64-a690-0f606980179f%40googlegroups.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/qYY7V0h2E0k/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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHn91of%3DZkDbjJGXqeRGP48_Xufz9ULXc8myaLiCBS%3Da1QR15w%40mail.gmail.com.

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



--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKd6oByrfqOSCMKamjdT_AFKQnP1dGZ7gbUdcj0Q9CkC5DeVVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment