sopython Posted April 12, 2019 Posted April 12, 2019 I want to use a static file. So I create a static folder under the project folder and put the file under the static folder. And I also added the needed info in settings.py, url.py and the html. But it still doesn't work. Is the something wrong in my files? Or there is something which need the admin's configure? What have been added in settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',... ...STATIC_URL = '/static/'STATIC_ROOT = os.path.join(BASE_DIR, 'static_collected') STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ]STATICFILES_FINDERS = ( "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder" *****************************************************************************What added in url.py: from django.conf.urls.static import static **************************************************What added in html: {% load static %} background-image: url("{% static "pyStocks/imgs/background-cloth.png"%}");
Krydos Posted April 14, 2019 Posted April 14, 2019 Did you add an exception for the static directory in your .htaccess?
sopython Posted April 15, 2019 Author Posted April 15, 2019 Oh, yes, that's the reason. It works after adding the exception. Thanks!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now