# Older Django <3.0 (also deprecated in 2.0):
from django.contrib.staticfiles.templatetags.staticfiles import static
# Django 3.0+
from django.templatetags.static import static
url = static('x.jpg')
url now contains '/static/x.jpg'
, assuming a static path of '/static/'
More Related Contents:
- Why does DEBUG=False setting make my django Static Files Access fail?
- View doesn’t return HttpResponse
- Hi I am new to Django Framework.getting error :No Module Named
- How to use permission_required decorators on django class-based views
- django 1.5 – How to use variables inside static tag
- Django – after login, redirect user to his custom page –> mysite.com/username
- Django : How can I see a list of urlpatterns?
- Execute code in Django after response has been sent to the client
- django – get() returned more than one topic
- How to handle request.GET with multiple variables for the same parameter in Django
- django: Purpose of django.utils.functional.SimpleLazyObject?
- Provide extra context to all views
- Can I call a view from within another view?
- Raw SQL queries in Django views
- ValueError: Missing staticfiles manifest entry for ‘favicon.ico’
- How can I list urlpatterns (endpoints) on Django?
- Example of Django Class-Based DeleteView
- django @login_required decorator for a superuser
- Redirect / return to same (previous) page in Django?
- Django – show loading message during long processing
- How to handle “matching query does not exist” when getting an object
- Django give Error 500 for all static files like CSS and Images, when DEBUG is False
- What is the right way to validate if an object exists in a django view without returning 404?
- Can I make STATICFILES_DIR same as STATIC_ROOT in Django 1.3?
- Django static files on heroku
- Forbidden (403) CSRF verification failed. Request aborted
- CSRF verification failed. Request aborted. on django
- Multiple form classes in django generic (class) views
- Make sure only one worker launches the apscheduler event in a pyramid web app running multiple workers
- Django / Comet (Push): Least of all evils?