custom admin urls routing wrong? #804
|
in one of my child model i have a change password custom urls def get_urls(self):
return [
path(
'<path:object_id>/password/',
self.admin_site.admin_view(self.mymodel_change_password),
name='mymodel_password_change',
),
] + super().get_urls()and when i try to access: the url become: and 1/password is catched as object id for the change view Any help ? |
Answered by
JohananOppongAmoateng
Jan 7, 2026
Replies: 3 comments
|
anyone ? |
0 replies
|
The issue is caused by using Fix: don’t use def get_urls(self):
return [
path(
'<int:object_id>/password/',
self.admin_site.admin_view(self.mymodel_change_password),
name='mymodel_password_change',
),
] + super().get_urls()This prevents |
0 replies
Answer selected by
bckohan
|
@bckohan I think we can convert this into a discussion |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is caused by using
<path:object_id>, which is greedy and captures1/passwordas the object ID, so Django routes it to the change view.Fix: don’t use
<path:object_id>in admin URLs. Use a non-greedy converter instead.This prevents
passwordfrom being swallowed by the change view and resolves the URL correctly.