Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: CSS file won't update

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:

enter image description here

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?

like image 678
almost a beginner Avatar asked Dec 19 '16 07:12

almost a beginner


1 Answers

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.

like image 128
almost a beginner Avatar answered Sep 20 '22 02:09

almost a beginner