Answer the question
In order to leave comments, you need to log in
Django stops seeing images from static because of the url. How to create url in this case?
On some pages, images from the static/image folder no longer appear on my pages, but at the same time, styles and scripts are also loaded from static without problems, only there was trouble with the pictures.
I was looking for a reason for a long time and accidentally found it. It turns out that if you add '/' to the address in any order, then images stop loading.
I'll give you an example. Here is the code from the main url:
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('Catalog.urls')),
path('arendators/', include('CatalogTenants.urls')),
]
urlpatterns = [
path('', MainPage.as_view(), name='main'),
path('QuickOrders', QuickOrdersPage.as_view(), name='quickOrders'),
path('NetArendators', GetArendators.as_view(), name='netArendators'),
path('information', Information, name='info'),
path('Buying', GetBuyPremises.as_view(), name='buying'),
path('Vacancy', Vacancy, name='vacancy'),
path('Deal', Deal.as_view(), name='deal')
]
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question