23👍
✅
YPCrumble, you would want to call the URL
with distinct kwargs
. The URL
regex works in a way to handle kwargs
. So for example:
# python reverse url
url = reverse('games-detail', kwargs={'team_pk': 1, 'group_pk':1})
# url regex
url(
r'^team/(?P<team_pk>\d+)/group/(?P<group_pk>\d+)/$',
view.SimpleRouterDetailView.as_view(),
name='games-detail'
)
-1👍
The issue seems to be related to the use of named groups in URL patterns. Using the args
parameter in the reverse
function, it’s causing a conflict with the named groups in URL pattern.
To address this issue, we can use the kwargs
parameter in the reverse
function to pass the values for the named groups. Here’s example:
url = reverse('games-detail', kwargs={'team_pk': team.pk, 'pk': game.pk})
For more comprehension:
- Is Django middleware thread safe?
- Create a Session in Django
- How to mock chained function calls in python?
- Django: How to automatically change a field's value at the time mentioned in the same object?
Source:stackexchange.com