Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load media/images #92

Open
fdiwa opened this issue Jan 2, 2022 · 2 comments
Open

Failed to load media/images #92

fdiwa opened this issue Jan 2, 2022 · 2 comments

Comments

@fdiwa
Copy link

fdiwa commented Jan 2, 2022

Hello,
Please to help me I push to de ploy the project all worked fine but the image in media even uploaded in my project pass 2 hours and give 404 error ,

in settings.py:
STATIC_URL = '/static/'
MEDIA_URL = '/media/'

Django debug toolbar

INTERNAL_IPS = ['127.0.0.1']

# Static files settings

PROJECT_ROOT = os.path.dirname(os.path.abspath(file))

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
#MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')

# Extra places for collectstatic to find static files.

STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)

and urls:

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

urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
path('', include('core.urls', namespace='core'))
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.DEBUG:
import debug_toolbar
urlpatterns += [path('debug/', include(debug_toolbar.urls))]
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT)
image

@singhayushh
Copy link

singhayushh commented Jul 17, 2022

The line PROJECT_ROOT = os.path.dirname(os.path.abspath(file)) might not be pointing to the right root. Please check and confirm once.

@4arjun
Copy link

4arjun commented Sep 10, 2023

base_dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants