Serving the stored images
Next, to enable the server to serve the stored images, we have to modify the /moviesstore/urls.py
file and add the following in bold:
… from django.conf.urls.static import static from django.conf import settings urlpatterns = [ path('admin/', admin.site.urls), path('', include('home.urls')), path('movies/', include('movies.urls')), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
With this, you can serve the media files stored in the MEDIA_ROOT
directory when the MEDIA_URL
URL prefix is accessed.
Note
It’s important to stop the server and run the server again to apply the previous changes.
Now that the image configuration is done, let’s add movies to the admin panel.