I'm having some issues changing Django Form's CSS. Here is my code (Template):
<form method="post" action="." id="signup">
<div class="container">
{% csrf_token %}
{{ form.as_p }}
<button type="submit" value="{% trans 'Submit' %}">Join</button>
</div>
</form>
Model:
class ExRegistrationForm(RegistrationForm):
age = forms.IntegerField()
location = forms.CharField()
phone = forms.CharField()
Model:
class ExUserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
age = models.PositiveSmallIntegerField(default = 19)
location = models.CharField(max_length=2, default = "location")
phone = models.CharField(max_length=15, default = "phone number")
def __unicode__(self):
return self.user
def user_registered_callback(sender, user, request, **kwargs):
profile = ExUserProfile(user = user)
profile.age = request.POST["age"]
profile.location = request.POST["location"]
profile.phone = request.POST["phone"]
profile.save()
CSS:
.container input[type=text], .container input[type=password], .container input[type=email], .container input[type=number] {
width: 100%;
padding: 0.3em 0.5em;
margin: 0.3em 0;
font-size: 1.5em;
text-align: center;
display: inline-block;
border: 0.1em solid #ccc;
box-sizing: border-box;
border-radius: 1em;
}
Result:
The style for my email and number field is not updating, I thought the issue might be related to Django forms auto generating the fields and doing something weird, but from inspect, it shows that the fields have normal names and input types. So nothing is out of the ordinary except the fact that the CSS isn't being update.
What am I doing wrong?
The issue was related to the fact that my browser had cached my old CSS file, therefore wouldn't show any updates. It was hard for me to solve the issue because I didn't really understand the problem.
The solution was quiet simple:
Ctrl + Shift + Del
In Chrome, you can use the above command to delete the cache, therefore allowing for the new static files to load.
Thanks for all the help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With