Accessing “Media” files in Django

前端 未结 7 2224
日久生厌
日久生厌 2020-12-02 03:54

I\'d like to love Django, but this business of static and media files in development environments is driving me nuts. Please rescue me from my stupidity.

I\'m on my

7条回答
  •  一个人的身影
    2020-12-02 04:52

    I followed timmy procedure but I got an error that No module name django.views. When I use import django.views in my virtualenv everything works fine i.e It's not an issue with the import of library.

    However, I was able to solve this problem by following this procedure in my main urls file

    from django.conf.urls.static import  static
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
    

    https://docs.djangoproject.com/en/dev/howto/static-files/

提交回复
热议问题