Kyle Kyle - 7 months ago 75
HTML Question

Django - Styling a UserCreationForm with css

The Django

UserCreationForm
is very useful and easy to use functionally, however, it just throws everything onto the page so all the
TextField
s are in one line.

Is there anyway to layout and style the form? Specifically to put
label
s and input fields on a new line and possibly make it possible to apply some CSS to the whole form and individual parts of the form.

Answer

Every django form has three methods:

as_p()
as_ul()
as_table()

See the outputting forms as html section in the docs. You can style this output as you want.

If you want even more control over form's html then read this section of the same documentation.