from django.urls import path
from . import views
app_name = 'posts'
urlpatterns = [path('', views.index, name='index'),
path('group/<slug:slug>/', views.group_posts, name='group_list'),
path('create/', views.post_create, name='post_create'),
path('posts/<int:post_id>/', views.post_detail, name='post_detail'),
path('profile/<str:username>/', views.profile, name='profile'),
path('posts/<int:post_id>/edit/', views.post_edit, name='post_edit'),
path('posts/<int:post_id>/comment/', views.add_comment, name='add_comment'),
path('follow/', views.follow_index, name='follow_index'),
path('profile/<str:username>/follow/', views.profile_follow, name='profile_follow'),
path('<str:username>/unfollow/', views.profile_unfollow, name="profile_unfollow"),
]
from django.urls import include, path
urlpatterns = [
# ... snip ...
path('community/', include('aggregator.urls')),
path('contact/', include('contact.urls')),
# ... snip ...
]
# path('create/', views.post_create, name='post_create') использование имени
<li>
<a href=" {% url 'posts:post_create' %}">Ссылка</a>
</li>
# Создания словаря для проверки сформированных путей
templates_url_names = {
reverse('posts:index'): 'posts/index.html',
reverse('posts:post_create'): 'posts/create_post.html',
}
from django.urls import reverse
def get_absolute_url(self):
return reverse('people-detail', kwargs={'pk' : self.pk})