Let’s say I have urls paths related to user authentication and others related to profiles (but could by about anything). I have all of them in the same app.
Like this:
urlpatterns = [
#Group profile URLs
path("profile_list/", views.profile_list, name="profile_list"),
path("profile/<int:pk>", views.profile, name="profile"),
path("profile/followers_list/<int:pk>", views.followers_list, name="followers_list"),
path(
"profile/followers_list/<int:pk>", views.followers_list, name="followers_list"
),
#Group user authentication URLs
path("login/", views.login_user, name="login"),
path("logout/", views.logout_user, name="logout"),
path("register/", views.register_user, name="register"),
path("update_user/", views.update_user, name="update_user"),
]
My question is: is it a good desgin pattern to separate and group them like this?
# Group profile URLs
profile_patterns = [
path("profile_list/", views.profile_list, name="profile_list"),
path("profile/<int:pk>", views.profile, name="profile"),
path(
"profile/followers_list/<int:pk>", views.followers_list, name="followers_list"
),
path("profile/follows_list/<int:pk>", views.follows_list, name="follows_list"),
]
# Group user authentication URLs
user_patterns = [
path("login/", views.login_user, name="login"),
path("logout/", views.logout_user, name="logout"),
path("register/", views.register_user, name="register"),
path("update_user/", views.update_user, name="update_user"),
]
# Combine all URL patterns into the main urlpatterns
urlpatterns = profile_patterns + user_patterns
Thanks!!