Issue
I have created two pages locally for Django site:
when I want to open "http://127.0.0.1:8080/about_me/" always opens this one "http://127.0.0.1:8080/portfolio/". Do you know reason for this?
project urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('blog.urls')),
path('portfolio/', include('blog.urls')),
path('about_me/', include('blog.urls')),
]
app urls.py:
from . import views
from django.urls import path
from django.conf.urls import include
urlpatterns = [
path('', views.PostList.as_view(), name='home'),
path('about_me/', views.Portfolio.as_view(), name='about_me'),
path('portfolio/', views.Portfolio.as_view(), name='portfolio'),
path('<slug:slug>/', views.PostDetail.as_view(), name='post_detail'),
path('summernote/', include('django_summernote.urls')),
]
# to jest dla wysiwyg
# add condition in django urls file
from django.conf import settings
from django.conf.urls.static import static
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
Solution
In your urls.py
both about_me
and portfolio
points to the same function.
path('about_me/', views.Portfolio.as_view(), name='about_me'),
path('portfolio/', views.Portfolio.as_view(), name='portfolio'),
Both urls
points to your Portfolio
view.
So change views
function name accordingly in your urls.py
.
path('about_me/', views.YourAboutMeView.as_view(), name='about_me'), #<---- change this view name accordingly
path('portfolio/', views.Portfolio.as_view(), name='portfolio'),
Answered By - user8193706
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.