Trying to add media files via admin.py, they do not appear in the folder they are supposed to be. Here is my code:
settings.py
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_in_dev', 'media_root')
As far as I understand, this means that all the downloaded media files are supposed to be saved in the project_folder/static_in_dev/media_root
models.py
class GalleryCupsModel(models.Model):
photo = models.ImageField(upload_to='cups/%Y/%m/%d')
And this is supposed to create folder 'cups' with year/month/day in the media_root folder, isn't it?
admin.py
class GalleryCupsAdmin(admin.ModelAdmin):
list_display = ['photo']
admin.site.register(GalleryCupsModel, GalleryCupsAdmin)
urls.py
urlpatterns = [
url(r"^cups/all/$", "gallery_cups.views.cups", name="cups"),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
project tree
├── gallery_cups
│ ├── migrations
│ │ └── __pycache__
│ └── __pycache__
├── LC
│ └── __pycache__
├── static_in_dev
│ ├── media
│ ├── media_root
│ ├── my_static
│ │ ├── css
│ │ ├── img
│ │ └── js
│ └── static_root
│ ├── admin
│ │ ├── css
│ │ ├── fonts
│ │ ├── img
│ │ │ └── gis
│ │ └── js
│ │ ├── admin
│ │ └── vendor
│ │ ├── jquery
│ │ └── xregexp
│ ├── css
│ ├── img
│ │ ├── header
│ │ └── portfolio
│ └── js
└── templates
The problem is the files, which I upload via admin.py, do not appear in the project_folder/static_in_dev/media_root, though I see them in the admin.py panel as a list of added images.
I've searched a lot but looks like I miss something crucial, but can not get what exactly. Will be thankful for any help.