A.objects.filter(a = 'aaa').filter(c = 'cccccccc')django
连锁查询 《=》A.objects.filter(a = 'aaa',c = 'cccccccc') 函数
当多对多的时候二者会有差别spa
前者的好处是:code
a = A.objects.filter(a = 'aaa')it
if XXXXX:import
a.filter(c = 'cccccccc')object
template filtermodel
{{ aaa|lower }}im
lower是函数查询
filter是函数调用
polls/ models.py templatetags/ __init__.py poll_extras.py views.py
{% load poll_extras %}
from django import templateregister = template.Library()
@register.filter
def lower(value): # Only one argument.
return value.lower()
本身写tags
https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/