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/