2

I added a user module to my project and I used the default Django user model for that. I've to change the styling to suit my other pages. The background color is black. The problem is default labels and error messages (eg: "username", "password", "Enter the same password as before for verification") generated by Django is also black and not visible now. How to change the label colors so that they are visible again? I'm a newbie to both development & StackOverflow, apologies if I have used incorrect terms or tags in my question. Thanks in advance.screenshot of the login form (highlighted is my problem

This is my forms.py (users app)

from django.contrib.auth.forms import UserCreationForm

class CustomUserCreationForm(UserCreationForm):
    class Meta(UserCreationForm.Meta):
        fields = UserCreationForm.Meta.fields + ("email",)

this is from my login.html

<h2>Login</h2> 

<div>
<form method="post" class="loginfrm">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Login" class="loginbtn">
</form>
</div>
ASIL ADNAN
  • 41
  • 1
  • 7
  • Look at [django's docs about rendering fields](https://docs.djangoproject.com/en/3.1/topics/auth/default/#django.contrib.auth.views.LoginView). After rendering each field you can add id/class name for styling. – Mubashar Javed Jan 30 '21 at 04:43
  • 1
    Thank you, where exactly can I do that? HTML/CSS or in my views or forms or such? – ASIL ADNAN Jan 30 '21 at 14:09
  • I find some parts of the Django documentation as difficult because I am a total beginner and cannot understand some terms. – ASIL ADNAN Jan 30 '21 at 14:11
  • adding my forms.py to the question. – ASIL ADNAN Jan 30 '21 at 15:26

1 Answers1

2

I've figured it out, thanks to Mubashar Javed's comment.

<form method="post" class="loginfrm">

I had to apply the style to this class, any style I apply to this class, only affects the labels. Exactly what I wanted.

<style>
.loginfrm {
    color: white;
}
</style>

you can see that my problem is now fixed.

ASIL ADNAN
  • 41
  • 1
  • 7