Hi, i;m new here, also in django developing,

Lastly i tried to create an app, something like a blog.  And I have created 
a Model with FK relations like this:  *Category=>Subcategory=>Post.*
Till here everything is fine, also when I create a Post in Admin Panel 
there is a char field to put the post url ex. post-nr-1

But  I want to make my app URL, friendly, just Url no '/ ' (single slug) . 
like this 

*click on category:  main/category-title-1*

*click on post: main/post-title-1 *

So just one URL, not slashing. 

urlpatterns = [
  path("", views.homepage, name = "homepage"),
  path("register/",views.register, name = "register"),  
   
        path("logout/", views.logout_request, name = "logout"),
  
        path("login/", views.login_request, name = "login"),
   
        path("<slug:single_slug>/", views.single_slug, name="single_slug"),
 
]




 View function mentioned before
def single_slug(request, single_slug): # Mund te pranojme single_slug si 
variabel neper  URL path 
# Me poshte kemi nje comprehensice List
categories = [c.category_slug for c in TutorialCategory.objects.all()] # 
c.category_slug : do marri vetem URL (slug) dhe do i ruaj ne liste. Pra 
shmang te dhena qe sna duhen
# c.category_slug => Bene te mudnur qe gjat ciklit for te zgjighen vetem 
category_slug ne objekte
if single_slug in categories:
matching_series = 
TutorialSeries.objects.filter(tutorial_category__category_slug=single_slug)
series_urls = {}
for m in matching_series.all():
part_one = 
Tutorial.objects.filter(tutorial_series__tutorial_series=m.tutorial_series).earliest("tutorial_published")
series_urls[m] = part_one.tutorial_slug
return render(request,"main/category.html",{"part_ones": series_urls})

tutorials = [t.tutorial_slug for t in Tutorial.objects.all()]
if single_slug in tutorials:
this_tutorial = Tutorial.objects.get(tutorial_slug = single_slug)
return render(request, 
  "main/tutorial.html",
  {"tutorial": this_tutorial})

return HttpResponse(f"{single_slug} does not correspond to anything!") 




*Now the posts and the category response ok, but if i try to go at  /admin 
or /login or  /logout  I get the response  ex. *admin does not correspond 
to anything!
*Even Even if I type a random url, it shows * {single_slug} does not 
correspond to anything! 

I think You understand me, waiting for a reply please

Images: 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61ea7af0-bc85-4238-ac3c-2c767dcaeca6%40googlegroups.com.

Reply via email to