Skip to content

django media folder #29

Open
Open
@amanpahariya

Description

@amanpahariya

i make a website on djnago i add image fields to django models and add settings.py media folder
and it work when i run website on localhost my media folder accept images and store inside it but when it push my website to heroku server it did not work when i insert images from admin page it upload successfully but it does not go inside my media folder and also not display on my website please help me
SETTINGS.PY

STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
STATIC_ROOT = os.path.join(BASE_DIR, "live-static-files", "static-root")
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "live-static-files", "media-root")
django_heroku.settings(locals())

MODELS.PY

class womens_fashions(models.Model):
id = models.IntegerField(primary_key=True)
images = models.ImageField(upload_to='pics1' , null = True, blank= True, default='default.jfif')
price = models.IntegerField()

URLS.PY

if settings.DEBUG is True:
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
please help me .....
thankyou in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions