[firefox]在地址栏使用通配符过滤书签及历史记录

通过在地址栏使用相应的通配符从而实现只搜索书签或历史记录的功能。

打开 about:config 搜索 urlbar

about:config urlbar

从上图可以看出,默认情况下相关通配符的功能如下:

browser.urlbar.match.title            #      只匹配标题
browser.urlbar.match.url              @      只匹配 URL
browser.urlbar.restrict.bookmark      *      只搜索书签
browser.urlbar.restrict.history       ^      只搜索历史记录
browser.urlbar.restrict.openpage      %      只搜索所有打开的标签页
browser.urlbar.restrict.tag           +      只搜索标签
browser.urlbar.restrict.typed         ~      只搜索曾经在地址栏输入过的记录(URL + 标题)

例如,只搜索标题包含 firefox 的记录 ...

more ...

[django] Variables and attributes may not begin with underscores

当尝试在模板中调用以下划线开头的对象时,会报如下类似错误:

TemplateSyntaxError at /

Variables and attributes may not begin with underscores: 'user._meta.get_field('name').help_text'

解决方法就是,将调用以下划线开头的对象的操作封装到模板过滤器中。

如何创建自定义模板过滤器

在 models.py 文件所在目录新建一个 templatetags 目录:

hello/
    models.py
    templatetags/
        hello_extras.py
        __init__.py
    views.py

hello_extras.py 中保存着我们自定义的模板过滤器。

在 hello_extras.py 文件的开头需要包含如下代码:

from django import template

register = template ...
more ...