#371 closed defect (fixed)
random filter in template throws an error
Reported by: | Boffbowsh | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Template system | Version: | |
Severity: | normal | Keywords: | |
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
Using {{loopimgs|random
}} in a template throws the following error:
There's been an error: Traceback (most recent call last): File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py", line 64, in get_response response = callback(request, **param_dict) File "/home/django/www/apps/browse/views/browse.py", line 14, in index return HttpResponse(t.render(c)) File "/usr/local/lib/python2.4/site-packages/django/core/template.py", line 115, in render return self.nodelist.render(context) File "/usr/local/lib/python2.4/site-packages/django/core/template.py", line 436, in render bits.append(node.render(context)) File "/usr/local/lib/python2.4/site-packages/django/core/template.py", line 466, in render output = resolve_variable_with_filters(self.var_string, context) File "/usr/local/lib/python2.4/site-packages/django/core/template.py", line 411, in resolve_variable_with_filters obj = registered_filters[name][0](obj, arg) File "/usr/local/lib/python2.4/site-packages/django/core/defaultfilters.py", line 235, in random return random.choice(value) AttributeError: 'function' object has no attribute 'choice'
loopimgs definately contains items, the var on it's own produces this:
[Baby_Cube.jpg, kids-hiding.jpg, kids2.jpg, girl_car.jpg, kids.jpg, kidsball.jpg]
Change History (5)
comment:1 by , 19 years ago
comment:3 by , 18 years ago
Has patch: | set |
---|---|
Resolution: | → fixed |
Status: | new → closed |
The patch is no longer valid as things have moved to another file, but the change it suggests has already been done so I assume that bug is solved. If not, please reopen.
Note:
See TracTickets
for help on using tickets.
Patch: