Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django media folder #29

Open
amanpahariya opened this issue Apr 29, 2020 · 0 comments
Open

django media folder #29

amanpahariya opened this issue Apr 29, 2020 · 0 comments

Comments

@amanpahariya
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant