[Django]-Django Userena Customization

8πŸ‘

βœ…

This is the signin method signature for Userena(source) –

def signin(request, auth_form=AuthenticationForm,
       template_name='userena/signin_form.html',
       redirect_field_name=REDIRECT_FIELD_NAME,
       redirect_signin_function=signin_redirect, extra_context=None):

As you can see, there is a template_name method that holds the template location. You can override this. In your urls.py, you can use it like –

url(r'^signin/', 'userena.views.signin', {'template_name': 'signin.html'}, name="signin"),

You can then create the signin.html page inside your templates folder and extend base.html. The signin view sends the login form in a variable called form. You can see the source. You can use the form on your template signin.html like {{ form.as_p }}. You can also format each field individually if you can follow the userena.forms. AuthenticationForm. Again, check the source code. You can do the same for any view Userena has that allows overriding like this.

When in doubt, read the source code. πŸ™‚

4πŸ‘

You need to override userena default templates.

Create a directory inside your templates/ named userena/, Then for example if you want to change signup form, easily create signup_form.html template file inside that userena/ dir that you’ve just created and start writing.

For instance here is default signup_form.html template.

You can find userena default templates at its github repo

1πŸ‘

Just copy the supplied userena templates in your template directory.

You can find them on a linux box with find / -name userena

The path you are looking for is ../userena/templates/userena. Copy the userena folder into your template directory and start changing the signin_form.html.

πŸ‘€Jay

0πŸ‘

Just copy the templates to your own template directory. If you follow this link download and just copy the directory β€˜userena’ to your template directory. You can then customise the templates including the email text and templates.

πŸ‘€Glyn Jackson

Leave a comment