Opened 12 years ago
Closed 12 years ago
#20881 closed Bug (fixed)
Remove contrib.auth.models.AbstractUser arbitrary definition of get_absolute_url
| Reported by: | Paul Garner | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.auth | Version: | 1.5 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
In AbstractUser class there is this code:
def get_absolute_url(self):
return "/users/%s/" % urlquote(self.username)
Firstly... I cannot see where this url pattern is defined - it's not in contrib.auth.urls - possibly this method should just be deleted from the class?
Secondly, if this url is defined somewhere and needed, I think the code should be:
def get_absolute_url(self):
return "/users/%s/" % urlquote(self.get_username())
I am happy to knock up a patch but would like to check I haven't misunderstood first.
Change History (4)
comment:1 by , 12 years ago
| Component: | Uncategorized → contrib.auth |
|---|---|
| Summary: | contrib.auth.models.AbstractUser get_absolute_url should call get_username → Remove contrib.auth.models.AbstractUser arbitrary definition of get_absolute_url |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Uncategorized → Bug |
comment:3 by , 12 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:4 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
I don't see any good reason for having this defined on
AbstractUser. For any site that doesn't implement a corresponding user view, this will create a broken "View on site" link in the admin. I think it's fine to remove it without a deprecation (open to objections), but it'll need a mention in the "backwards incompatible changes" section of the release notes.If we remove the method, one test will need to be updated to use a different model:
====================================================================== FAIL: test_shortcut_view_only_available_to_staff (admin_views.tests.SecureViewTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/timgraham/code/django/tests/admin_views/tests.py", line 1755, in test_shortcut_view_only_available_to_staff self.assertEqual(response.status_code, 302) AssertionError: 404 != 302