django not loading static files on shared hosting

I have not created any django apps and i have created views, models and admin files in the single project folder. This is the first time ive done it this way but when i deploy it its not loading any static files.
directory tree :

settings.py :

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    # own apps #
    'cia_maria',
    'ckeditor',
    
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    "whitenoise.middleware.WhiteNoiseMiddleware",
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

STATIC_URL = 'static/'
if DEBUG:
    STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
else:
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

urls.py :

from django.contrib import admin
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static

from .views import home_view, about_view, study_view, jobs_view, single_view 


urlpatterns = [
    
    path('admin/', admin.site.urls),
    path('',home_view, name='home'),
    path('about/',about_view, name='about'),

    path('study/', study_view, name="study"),
    path('jobs/', jobs_view, name="jobs"),
    path('single/<slug:sid>/', single_view, name="single"),

] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)

what could be the possible issue here?
should i start an app and use those views, models and admin?
Because there is no problem with other websites that i have deployed (which had seperate apps in them)

1 Like

Sorry it was not Django, i had the files in a wrong directory. Should i remove this post?

last time i faced the same issue, then i solved myself. I did like this: in my settings.py file

STATIC_URL = ‘static/’
STATIC_ROOT =“/home/robonaia/public_html/static/”
STATICFILES_DIRS = [
os.path.join(BASE_DIR, “static”)
]

use =“/home/robonaia/public_html/static/” your statics files should be on public_html file; and run this command: python manage.py collectstatic

hope it will work for you.

you can remove the post. it this is not that or edit the post.