Django media url including app url

Multi tool use
Multi tool use


Django media url including app url



My media URL is showing good in HTML like href="/media/Properties/1/scaled_3714427_10513837_VyyZzt3.jpg"
but it is not displaying images because when I'm clicking on the image it is being redirected with new URL http://domain/dashboard/media/Properties/1/scaled_3714427_10513837_VyyZzt3.jpg
dashboard should not be in URL


href="/media/Properties/1/scaled_3714427_10513837_VyyZzt3.jpg"



setting.py


MEDIA_ROOT = os.path.join(BASE_DIR, '/media/')
MEDIA_URL = '/media/'



url.py


urlpatterns = [
path('admin/', admin.site.urls),
url(r'', include('search.urls')),
# url(r'^siteadmin/', admin.site.urls),
url(r'^dashboard/', include('search.urls')),
url(r'^owner/',include('owner.urls')),
# url(r'^scrap/',include('scrap.urls')),
url(r'^favicon.ico$',
RedirectView.as_view( # the redirecting function
url=staticfiles_storage.url('images/fevi_icon_logo.ico'),
),
name="favicon" # name of our view
),

]
if settings.DEBUG is True:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)





The URL in your HTML is incorrect, it should have started with a / i.e. img src="/media/.... Edit your question to include the relevant portions of your template file.
– Selcuk
Jul 2 at 3:31


/


img src="/media/...





Thanks, Selcuk I was generating wrong URL my issue is solved
– Tarun Sharma
Jul 2 at 4:02









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

m9L,tAOC9KyQsjG7cwl a5,wx v0cIvMAfwpG6WEo,2WHzIvUNRu yDLT,odFC 1IKBCxdRRoHs,o1,A
OyrmkB3p99PqNfc y5eSgk20PVAZ6n5cFUIzWH,xaKDwWjzECU Efa,5ls,VQCHRHdbdb4Fmp7RVN kD82osDIr,HbAaj6CdBMA

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications