I’m building a reusable app for a custom user model with login, registration, listing, deleting, and updating handled by the reusable app. I’ve set my reusable app urls.py as:
app_name = "users"
urlpatterns = [
path('list/', UserListView.as_view(), name="user_list"),
...
]
Inside the template of user List:
...
<a href="{% url 'user_detail' user.id %}" class="btn btn-secondary text-white"> View</a>
<a href="{% url 'user_edit' user.id %}" class="btn btn-primary text-white"> Edit</a>
<a href="{% url 'user_delete' user.id %}" class="btn btn-danger text-white"> Delete</a>
I’m trying to use the URLs of this app in my main app as follows:
urlpatterns = [
...,
path('users/', include('users.urls', 'users'),
]
When I run my reusable app separately then these url’s doesn’t have any problem, but when I try to access the URLs of users app then I get reverse for ‘url_name’ not found.
How can I make it so that the URLs of ‘users’ app can be used seamlessly in the main app?
or how can I use {% url ‘users: user_list’ %} and the reusable app doesn’t throw error and main app works fine?