In my setting.py I have next code:
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATICFILES_DIRS = [
os.path.join(PROJECT_DIR, 'static'),
]
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
And in views.py I want to get some of the images inside static folder as follows:
for f in ["static/img/logo/contact-form/logo_black.png", "static/img/logo/contact-form/logo_white.png":
fp = open(os.path.join(BASE_DIR, f), 'rb')
msg_img = MIMEImage(fp.read())
fp.close()
msg_img.add_header('Content-ID', '<{}>'.format(f))
msg.attach(msg_img)
But I'm getting an error:
"[Errno 2] No such file or directory: '/Users/Admin/Projects/web-dealers/webDealers/static/img/logo/contact-form/logo-black.png'"
UPDATE
The urls.py is as follows:
urlpatterns = [
url(r'^django-admin/', admin.site.urls),
url(r'^admin/', include(wagtailadmin_urls)),
url(r'^documents/', include(wagtaildocs_urls)),
url(r'^search/$', search_views.search, name='search'),
url(r'^api/', include('API.urls')),
url(r'^contact-us/', contact_us, name="contact_us"),
# Languages
url(r'^i18n/', include('django.conf.urls.i18n'), name='set_language'),
url(r'^jsi18n/$', JavaScriptCatalog.as_view(), name='javascript-catalog'),
# For anything not caught by a more specific rule above, hand over to
# Wagtail's page serving mechanism. This should be the last pattern in
# the list:
url(r'', include(wagtail_urls)),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
What am I doing wrong?