Open fdiwa opened 2 years ago
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/'
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')
# 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)
The line PROJECT_ROOT = os.path.dirname(os.path.abspath(file)) might not be pointing to the right root. Please check and confirm once.
base_dir
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']
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')
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)