378π
If you have any of the following tags in your template:
{% load staticfiles %}
{% load static from staticfiles %}
{% load admin_static %}
Then replace it with:
{% load static %}
You have to make this change because {% load staticfiles %}
and {% load admin_static %}
were deprecated in Django 2.1, and removed in Django 3.0.
20π
- Try
{% load static %}
instead of{% load staticfiles %}
- If effect of CSS or any other files doesnβt reflect in your template then also write following lines in the end of your
settings.py
file
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
VENV_PATH = os.path.dirname(BASE_DIR)
STATIC_ROOT = os.path.join(VENV_PATH, 'static_root')
- [Django]-Sending HTML email in django
- [Django]-Django Generic Views using decorator login_required
- [Django]-Why doesn't django's model.save() call full_clean()?
9π
This worked for me using django 3.1.4.
{% load static %}
<link rel="stylesheet" href="{% static 'style.css' %}">
its working for me
- [Django]-Django create userprofile if does not exist
- [Django]-Django can' t load Module 'debug_toolbar': No module named 'debug_toolbar'
- [Django]-How to delete project in django
2π
this worked with me replace {% load static from staticfiles %}
with {% load static %}
where :
go to your virtual environment "venv" /lip/python3.X/site-packages/leaflet/templates/leaflet/admin/widget.html and all of the .HTML files in the directory
- [Django]-Is there a way to loop over two lists simultaneously in django?
- [Django]-Heroku, postgreSQL, django, comments, tastypie: No operator matches the given name and argument type(s). You might need to add explicit type casts
- [Django]-Django.db.migrations.exceptions.InconsistentMigrationHistory
0π
My issue was in step 4 from documentation here: https://docs.djangoproject.com/en/3.2/howto/static-files/
"4. Store your static files in a folder called static in your app. For example my_app/static/my_app/example.jpg."
Once I had corrected my directory structure to match everything worked.
- [Django]-How to set a value of a variable inside a template code?
- [Django]-Django py.test does not find settings module
- [Django]-Django β SQL bulk get_or_create possible?
0π
I encountered the same problem and attempted to resolve it using various methods. However, I eventually modified the next line of code where I referenced my CSS file. The solution is identical to the one mentioned above, but with an additional step.
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'css/style.css' %}"/>
changed with :
{% load static %}
<link href="{% static 'css/style.css' %}" rel="stylesheet">
- [Django]-What's the best way to store a phone number in Django models?
- [Django]-Django-tables2: How to use accessor to bring in foreign columns?
- [Django]-How to test auto_now_add in django