I have a custom module and need to create a custom template filter. I used this reference http://meta.osqa.net/questions/5528/can-a-forum-module-define-template-tags and created this setup:

in mymodule_tags.py:

from forum.templatetags.extra_tags import register
@register.filter
def customfilter(value):
    return 1 #will edit this to do something based on "value"

in startup.py:

from mymodule_tags import *

in mytemplate.html:

{% load extra_tags %}
{{ myvalue|customfilter }}

however, this just gets me the error: invalid filter 'customfilter'

asked 10 Nov '10, 15:15

rsp's gravatar image

rsp
41661420
accept rate: 66%

edited 31 Dec '10, 11:15

rickross's gravatar image

rickross ♦♦
12.5k2914972


Try changing your startup.py to this:

import mymodule_tags

Otherwise, that looks like it should work.

link

answered 19 Dec '10, 18:27

Kevin%20Yank's gravatar image

Kevin Yank
436111824
accept rate: 28%

@Kevin Yank: that didn't fix it (btw, thanks for the reply). I looked over it several times now and I don't think I have any typos or things like that. mymodule_tags.py and startup.py should both be placed in my module's main folder, correct? I can't imagine why this isn't working.

(20 Dec '10, 20:56) rsp

I faced the same problems-- and figured out a solution. Does this answer work for you?

http://meta.osqa.net/questions/6277/how-to-enable-my-osqa-modules-custom-tag-to-load-a-custom-filter

link

answered 27 Dec '10, 00:34

Justin%20Grant's gravatar image

Justin Grant
1.1k163532
accept rate: 12%

@Justin Grant thanks, but that doesn't seem to work either. I even checked out the latest osqa release to see if that helped. I have the exact problem you described: if my module is in the forum/templatetags folder everything works fine, but if its in my module's folder it doesn't work. I tried your solution, which seems like it should work, but it doesn't.

(31 Dec '10, 21:34) rsp
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×69
×44
×24
×23
×11

Asked: 10 Nov '10, 15:15

Seen: 1,422 times

Last updated: 21 Jan '11, 15:14

powered by OSQA