1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Why the Django static files are not loading after deployment? [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    I know this question has similar ones but nothing has been able make it for me. I've tried everything and every possible solution yet nothing helped including running all commands like python manage.py collectstatic.

    [​IMG]

    [​IMG]

    settings.py:

    # Media files (Uploaded files)

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

    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/5.0/howto/static-files/

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

    STATICFILES_DIRS = [
    os.path.join(BASE_DIR,'static')
    ]


    urls.py:

    from django.urls import path
    from .views import *
    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = [
    path('', home, name="home"),
    path('signup/', signup_view, name='signup'),
    path('activate/<uidb64>/<token>/', activate, name='activate'),
    path('login/', login, name='login'),
    path('logout/', logout, name='logout'),
    path('myprofile/', profile, name='profile'),
    path('myprofile/update', PROFILE_UPDATE, name='profileupdate'),
    path('reservation', reservation, name='reservation'),
    path('checkout/', checkout, name='checkout'),

    # Cards
    path('vegndaal/', vegndaal_page, name='vegndaal_page'),
    path('chicken/', chicken_page, name='chicken_page'),
    path('mutton/', mutton_page, name='mutton_page'),
    path('rice/', rice_page, name='rice_page'),
    path('tandoor/', tandoor_page, name='tandoor_page'),
    path('paratha/', paratha_page, name='paratha_page'),
    path('breakfast/', breakfast_page, name='breakfast_page'),
    path('fish/', fish_page, name='fish_page'),
    path('wrapsandsandwiches/', wrap_page, name='wrap_page'),
    path('burgersandwiches/', burger_page, name='burger_page'),
    path('combosandwiches/', combo_sandwiches, name='combo_sandwiches'),
    path('clubsandwiches/', club_sandwiches, name='club_sandwiches'),
    path('freshjuices/', juices_page, name='juices'),
    path('salads&softdrinks/', salad_page, name='salad'),
    path('milkshakes/', milk_shakes, name='milkshakes'),
    path('tea&coffee/', teancoffee, name='tea&coffee'),
    path('bbq/', bbq_page, name='bbq_page'),
    path('desserts/', desserts_page, name='desserts'),
    path('plateitems/', plate_items, name='plateitems'),
    path('grilled-tandoor/', grilled_tandoori_page, name='grilled_tandoori_page'),
    ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)


    The directory structure:

    Restaurant/
    │
    ├── app/
    │ └── public/
    │
    ├── Restaurant/
    │
    ├── static/
    │ ├── colors/
    │ ├── css/
    │ ├── images/
    │ ├── js/
    │ └── plugins/
    │
    ├── staticfiles/
    │ ├── admin/
    │ ├── colors/
    │ ├── css/
    │ ├── images/
    │ ├── js/
    │ └── plugins/
    │
    ├── templates/
    │
    └── tmp/

    Continue reading...

Compartilhe esta Página