[Fixed]-Django Registration Redux Customize

1👍

If i understood you correctly you would like to access individual fields. To access them you can get the fields’ names here.

So in the template instead of {{ form.as_p }} you could use individual fields like this:

for e.g. {{ form.username }}.

If you also would like to add styling then you need to use filters like:
{{ form.username | add_some_css:”my_new_class” }}. This styling needs to be configured in a separate file for e.g. redux_css.py. To make your template use this file you need to include after {% extends ‘base.html’ %} the following {% load redux_css %}.

Now you need to create redux_css.py:

from django import template

register = template.Library()

@register.filter
def add_some_css(field, css):
    """
    Adds css to fields in Redux templates
    """
    return field.as_widget(attrs={"class":css})

All this should make your redux fields (which are text inputs) styled like: class=”my_new_class”

Obviously you need to create .css files and “import” them into your .html files.

PS you might need to access fields errors as well, you can do this with {{ form.username.erros }}

Leave a comment