i am having a problem uploading files to my server (shareserver) in cpanel.
when I upload a file either by admin or by a view it responds 404
if someone has help I would be very grateful
settings
DEBUG = True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static/'),)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media/')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
os.path.join(BASE_DIR, 'media'),
)
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware', ...
urls
...] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT, show_indexes= True
) + static(
settings.STATIC_URL, document_root=settings.STATIC_ROOT
)
model
class Product(models.Model):
name = models.CharField(max_length=50)
produc_pic = models.ImageField(default = '',null=True, blank=True)
.htaccess
<IfModule Litespeed>
WSGIScriptAlias / /home/ibhfrwld/ferre-bianconeri/ferreteria-bianconeri/ferre/wsgi.py
<Directory /home/ibhfrwld/ferre-bianconeri/ferreteria-bianconeri/ferre>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /media/ /home/ibhfrwld/ferre-bianconeri/ferreteria-bianconeri/media/
Alias /static/ /home/ibhfrwld/ferre-bianconeri/ferreteria-bianconeri/static/
<Directory /home/ibhfrwld/ferre-bianconeri/ferreteria-bianconeri/static>
Require all granted
</Directory>
<Directory /home/ibhfrwld/ferre-bianconeri/ferreteria-bianconeri/media>
Require all granted
</Directory>
</IfModule>
yes in settings.py [DEBUG = True] and only show 404 page not found error, i can't see more detail error
- kopacanova47 4 years, 9 months agook so page are also rendering perfectly right? . Only image is not able view, If that is the case, did you run collectstatic?
- scott 4 years, 9 months agoyeap i run collectstatic before turn on server on cpanel. and all statics like css and js are runing normal
- kopacanova47 4 years, 9 months agomay be try change the MEDIA file directory, looks like its not pointing to the right folder, MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
As we are not getting any update on this ticket. We are closing the ticket.
- Vengat
Ok seems like some kind of permission or setting issue. As you have enabled DEBUG true, you should able able to see the what the actual error detail right?