Django registration redux form

1

Good afternoon,
I would like to know how I can edit the style of my form, I do not want it to appear all at once, I use 'form | crispy' to call the form. I am also using 'django registration redux'. How can I do so that for example in the "input" put a "placeholder"? I also want to remove the 'label' from the form.

This is my "login.html":

{% extends "index.html" %}
{% load crispy_forms_tags %}
{% load i18n %}

{% block content %}
<form method="post" action=".">
  {% csrf_token %} 
  {{ form|crispy }}

  <input type="submit" value="{% trans 'Iniciar sesion' %}" class="btn btn-primary"/>
  <input type="hidden" name="next" value="{{ next }}" />
</form>

<p>{% trans "Has olvidado tu contrasena" %}? <a href="{% url 'auth_password_reset' %}">{% trans "Restablecer" %}</a>!</p>
<p>{% trans "No tienes cuenta" %}? <a href="{% url 'registration_register' %}">{% trans "Registrarte" %}</a>!</p>
{% endblock %}

Thanks in advance and best regards!

    
asked by manuxdjent 03.04.2017 в 17:55
source

1 answer

0

First of all, you do not do that in the template, but in the definition of the form.

For example, in the following fragment, we set the placeholder and hide the labels in the form ProductividadForm

class ProductividadForm(forms.Form):
     modulo = forms.CharField(max_length = 80, required=True)

    def __init__(self, data=None, files=None, **kwargs):
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Field('modulo', placeholder="Escribe la clave del MAC"),
        )
        self.helper. form_show_labels = False
        super(FilterForm, self).__init__(data, files, **kwargs)

See the documentation on FromHelper .

    
answered by 04.04.2017 в 21:42