7
7
7a-6662020-02-10 13:45:46
Django
7a-666, 2020-02-10 13:45:46

Working with images in django?

1) There are 2 models Products and Images_Products Images_Products
are linked by key one-to-many with products one product can have many images
So how to combine so that you can immediately add products together with images in the admin panel?

2) As I understand it, I create my own url for each picture with this code

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


static() - the documentation says
"Helper function to return a URL template for serving files in debug mode "
i.e. when I throw on hosting and turn off DEBUG this function will not work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-02-10
@7a-666

1. InlineModelAdmin
2. As for the test, it will not be, in the production the web server distributes statics, not django. You need to configure MEDIA_URL and MEDIA_ROOT
All this is in the docks, it remains to learn how to read them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question