django on cpanel returnt 404 uploading file

Hello, I am a little new deploying a project in django, this is a personal one for my master’s thesis, I am having problems uploading files from django in a namecheap share hosting. if anyone has a guide or something i’m not doing well in the apache configuration please i would be grateful for the help

I leave the link to stack overflow but if you want to read part of what is there I will leave it down here

when I upload a file either by admin or by a view it responds 404

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)

I am experiencing a similar issue which I’ve added to this thread:

This seems to be specific to Apache/cPanel for reasons unknown. As far as I can tell it’s an issue with the URL dispatcher or server configuration but I haven’t made any progress yet.

I’ve developed a temporary workaround that may work for you until a cleaner solution becomes available:

1 Like