Posts

Showing posts with the label django-urls

Django media url including app url

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$', Redi...

Django url namespaces giving errors

Django url namespaces giving errors I am new to the django framework. I currently started learning from an online video tutorial and I came across some errors. I have an app called groups which has two separate view files namely company and family. Due to that I have my groups/url file as this: from django.urls import path, include, re_path from . views import company from . views import family app_name = 'groups' company_patterns = [ path('create/', company.Create.as_view(), name='create'), re_path(r'^edit/(?P<slug>w+)/$', company.Update.as_view(), name='update'), path('<str:slug>/', company.Details.as_view(), name='detail'), ] family_patterns = [ path('create/', family.Create.as_view(), name='create'), path('edit/<str:slug>/', family.Update.as_view(), name='update'), path('<str:slug>/', fami...