#11891 closed (fixed)
The attributes of the original get_absolute_url defined in the model is not copied
Reported by: | Nils Fredrik Gjerull | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.1 |
Severity: | Keywords: | attributes get_absolute_url | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have made an app that assist in purging upstream web caches and it uses, among other methods, get_absolute_url. Because I don't always want to purge based on get_absolute_url I added an attribute to get_absolute_url named purge. This attribute gets lost because get_absolute_url is changed with the get_absolute_url that do absolute url overrides, curried with the original function. The original function's attributes should be added to the new curried function.
class AModel(models.Model): def get_absolute_url(self): return '/some_url/' get_absolute_url.purge = True
Attachments (1)
Change History (10)
by , 15 years ago
Attachment: | get_absolute_url_attributes.diff added |
---|
comment:1 by , 15 years ago
milestone: | → 1.2 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:4 by , 15 years ago
comment:5 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
need to fix models.permalink decorator
and #12836 market as duplicate
comment:6 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
The fix in [12766] included unit tests to check that this works, and the tests pass; without proof that the fix didn't actually work, this shouldn't be reopened.
comment:7 by , 15 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
copy & paste from #12836
class MyModel(models.Mode): @models.permalink @set_attr('x', 10) # set some attribute to MyModel.get_absolute_url method def get_absolute_url(self): return ('some', (self.attr, )) >>>print MyModel().get_absolute_url.x AttributeError: 'function' object has no attribute 'x'
comment:8 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
The problem here is that #12836 shouldn't have been closed as dupe in the first place. This ticket is about problems with the replacement of get_absolute_url in ModelBase, which is now fixed. #12836 is about @models.permalink not updating wrappers, which is a valid, but separate issue. Re-closing this as fixed, reopening #12836.
Preserve attributes of the original get_absolute_url method