Field RichTextField sem ser Admin

37 views
Skip to first unread message

Daniel França

unread,
Jun 20, 2012, 1:27:09 PM6/20/12
to mezzani...@googlegroups.com
Olá, pessoa.
Estou tentando utilizar o campo RichTextField em um formulário que estou criando para o meu site, porém quando entro com um usuário que não é superuser o campo aparece como textarea simples, tem alguma configuração que preciso mexer ou algo que posso fazer para que mesmo os usuários simples tenham acesso ao  RichTextField?

Abs,
Daniel França

Leandro Ferreira

unread,
Jun 20, 2012, 1:34:05 PM6/20/12
to mezzani...@googlegroups.com
Fala Daniel, vou botar sua dúvida em inglês senão o pessoal vai ficar perdido aqui:

I took the liberty of translating Daniel's question:
I'm trying to use a RichTextField on a form I'm creating for my site, but when a regular user (not useruser) opens the page, the field is shown as a simple textarea. Am I missing something? Do I have to configure anything else so regular  users can see this RichTextField?



   @leandroferreira
   55 61 91151257



2012/6/20 Daniel França <daniel...@gmail.com>

Daniel França

unread,
Jun 20, 2012, 2:49:59 PM6/20/12
to mezzani...@googlegroups.com
Sorry guys, I just forgot this is an english language group.

My mistake... =/

And thank you, Leandro.


2012/6/20 Leandro Ferreira <dur...@gmail.com>

Stephen McDonald

unread,
Jun 20, 2012, 4:38:09 PM6/20/12
to mezzani...@googlegroups.com
You should be able to get it working by simply writing out {{ form_var.media }} in your template where form_var is your form object.

The RichTextField includes media definitions which contain all the JavaScript files needed to load the TinyMCE editor (https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/forms.py#L39) which Django then adds to the media definition for any form that contains that field.

2012/6/21 Daniel França <daniel...@gmail.com>



--
Stephen McDonald
http://jupo.org

Rainell Dilou Gómez

unread,
Oct 12, 2017, 5:47:59 PM10/12/17
to Mezzanine Users
Hello,
if I write {{form.media}}, as in the following example, Mezzanine render the TinyMCE editor, but the contents of the field is saved only if the authenticated user is a superuser. If the authenticated user is not a superuser, the contents of the RichTextField type field after submit form is blank. This occurs only with the RichTextField type field.
Anyone know why?

<form method="POST">
    {% csrf_token %}
    {{ form.media }}
    {{ form.as_p }}
   
<button type="submit">{% trans "Submit" %}</button>
</form>

Rainell Dilou Gómez

unread,
Oct 13, 2017, 5:39:55 AM10/13/17
to Mezzanine Users
Ok, I solved the problem. First I have put form.media where it should be, in the header. But that did not change the behavior I described in the previous post. Then I have replaced form.as_p with fields_for form, removing csrf_token because fields_for creates the token automatically. So, in this way, it has worked:

{% extends "base.html" %}
{% load mezzanine_tags i18n %}

{% block extra_head %}
   
{{ block.super }}
   
{{ form.media }}
{% endblock %}

{% block main %}
       
{% block my_form %}
       
<form method="post">
           
{% fields_for form %}
           
<button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
       
</form>
       
{% endblock %}
{% endblock %}



Il giorno mercoledì 20 giugno 2012 19:27:09 UTC+2, Daniel França ha scritto:
Reply all
Reply to author
Forward
0 new messages