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>
3
Answers
do not apply exactly this solution in this thread Django admin 404 error when creating or editing a model instance nor the one you suggest but if I talk to him support team and I asked them to deactivate the "modsec" that was previously available in cpanel, they ask you why and you tell them that due to the incompatibility with django and voila, if you need to activate it again, you contact them again.
after this everything worked correctly
I find solution here,
https://smartlazycoding.com/django-tutorial/deploy-a-django-website-to-a2-hosting
I encounter the same issue. It was causes by passenger_wsgy.py. Initially I was only used
from mysite.wsgi import application
it won’t work, so I uses the code below, It work fine for me
We’re sorry, but something went wrong.
The issue has been logged for investigation. Please try again later.
I got the above error after changing from my_project.wsgi import application
To yours I still get the same error.