1👍
It was because the folder didn’t have necessary permissions and Django was unable to access it.
0👍
in url.py have you configurated staticfiles?
if settings.DEBUG:
urlpatterns += patterns('',
#REMOVE IT in production phase
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT})
)
urlpatterns += staticfiles_urlpatterns()
- How do I query objects of a ManyToManyField?(without through)
- In django, values(*field) doesn't give all values of ForeignKey field with sliced queryset
- 502 Bad Gateway nginx/1.1.19 on django
- How to calculate the dfference between two variables in Django?
0👍
There are a few changes to make here. You can copy and paste the following code below for your template, and the settings below that in your urls.py:
html:
{% load staticfiles %}
<html>
<head>
<title>Login | Mess @ IIIT Sri City</title>
<link rel="stylesheet" type="text/css" href="{% static 'mess/css/style.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'mess/css/bootstrap.min.css' %}">
</head>
<body>
<div class="container">
<div id="left-content" class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<center><img src="{% static 'mess/img/burger.jpg' %}" alt="Please Login here" /></center>
</div>
<div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
<form action="" method="post">{% csrf_token %}
{{ form }}
<input type="submit" value="Submit" />
</form>
</div>
</div>
</body>
</html>
urls:
if settings.DEBUG:
urlpatterns += patterns('',) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += patterns('',) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
In the html, I added {% load staticfiles %}
at the top to keep your code DRY (Don’t Repeat Yourself). I also made a few syntax changes to your code; very minor. In the urls, when your settings are set to DEBUG = True
, Django will load your static images. When you go into production and DEBUG = False
, Django no longer serves the static files. That is your server’s responsibility.
I hope that helps.
If it still doesn’t work, can you please post your STATIC_URL
and STATIC_ROOT
?
- Formatting job returned from input with Jquery
- Django Bootstrap Data Toggle Radio Buttons Not working
- Building cascade structure
- How to loop over a queryset for instantiate all formset?
- Invalid PDF structure with Django and API REST