I a trying to add some style to the UserCreationForm, I cannot user Bootstrap for this project so need to modify its html and css directly. I have not been able to find anything in its documentation the allows me to do this.
I added a email field to my UserCreationForm field by adding this snippet of code to models.py
class CreateUserForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
and I pass the form as context to my template in views.py
def register(request):
if request.method == 'GET':
if request.user.is_authenticated:
return redirect('news')
else:
form = CreateUserForm()
context = {'form': form}
return render(request, 'base1.html', context)
if request.method =='POST':
form = UserCreationForm(request.POST)
if form.is_valid():
form.save()
user = form.cleaned_data.get('username')
messages.success(request, 'Account was created for ' + user)
return redirect('login')
return render(request, 'registration.html', context)
this is how I have manage to display it inside my HTML5 template
<form action="" method="post">
{% csrf_token %}
<h1 class="t34"> Register </h1>
<div class="t34">{{form.username.label}}</div>
{{form.username}}
{{form.email.label}}{{form.email}}
{{form.password1.label}}{{form.password1}}
{{form.password2.label}}{{form.password2}}
<input type="submit" name="Create User">
</form>
More over I have looked at several tutorials and did not find what I was looking for as well as an Stackoverflow where this answers seem to help but since they are years old the links are no longer valid and I have no way of looking at the documentation.
Django - Styling a UserCreationForm with css from 5 years ago
How do I style my user registration form using Bootstrap in DJango? from 5 years ago and please no bootstrap.
So how do I modify the style of the fields in UserCreationForm and ad my own css and/or html?
And where can I find the documentation for this? (I have looked at the documentation site many times but it is huge and I can't seem to find anything about this.)