I am deploying my Django site on A2 Hosting.
I can get the page to display but no static files (images/css) are loading.
I have this in my settings.py:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ROOT_PATH = os.path.dirname(__file__)
STATICFILES_DIRS = [os.path.join(ROOT_PATH, 'static')]
my urls.py:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('mysite.urls')),
url(r'^$', TemplateView.as_view(template_name='static_pages/index.html'), name='home'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
I am running python manage.py collectstatic
in the terminal. It is creating a static
folder with a file structure including admin
and subfolders within that admin folder. My images and css files are appearing in the newly generated static
file (in the base folder) yet neither the css nor my images are showing on my webpage (I've been restarting my server).
My link to my css file within my html template is:
<link rel="stylesheet" href="{% static 'style.css' %}" type="text/css">
This is done on shared hosting, I have debug set to false, and it works in development.
/home/mysite
->etc
->mysite
-->__pycache__
-->webpage
--->static
---->webpage
----->image.jpg
----->style.css
--->templates
---->webpage
----->index.html
-->main_webpage
--->settings.py
-->public
-->static_files (generated by collectstatic)
--->admin
--->image1
--->style.css
-->template
-->tmp
->logs
...
Thank you.