简体   繁体   中英

Why should I only allow image upload during DEBUG mode?

I want to add a field for users to edit their profile pictures and checked out a few tutorials. However, every tutorial I've found included some form of this in urls.py:

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT

Why can't I do this with deployment and if it has to be like this? Is there any way for me to allow users to upload and modify their profile pictures?

Any help would be appreciated. Thanks.

This is because in production mode django stop serving static files. Thus static url will result in a page not found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM