problem is the return statement. when the dictionary req is empty the
def returns u"" and somehow old request.GET remains unchanged. So i
should return a specific value, when the dictionary req is null.
2011/6/2 ozgur yilmaz <yelbuke@gmail.com>:
> Hi,
>
> I have a custom templatetag function like this:
>
> @register.filter(name='rem_get_request')
> def rem_get_request(getrequest,name):
> req = getrequest.copy()
>
> for get_item in name.split('&'):
> if get_item in req and req[get_item]:
> get_item = get_item.strip()
> del req[get_item]
>
> if req:
> return u"?%s" % (req.urlencode())
> return u""
>
> "getrequest" parameter is request.GET
> and "name" parameter is the parameters to be removed, splitted by '&'
> (ampersand) (ie "min_price&max_price" )
>
> The problem is:
> If request.GET has more than 1 parameter (
> ?tag=mytag&min_price=1000&max_price=1500 ) i can remove one or more
> parameters. But if request.GET contains only one parameter (
> ?tag=mytag ) then it doesnt work. the "if" statement works, but "del"
> doesnt work. i cannot remove this last parameter. What am i doing
> wrong?
>
> Thanks for your information.
>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment