Module Expr Str ImportFrom alias ClassDef bases AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr keyword Num keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr keyword Num keyword Str ClassDef bases body Assign NameStore Str decorator_list FunctionDef arguments args NameParam defaults body Return AttributeLoad NameLoad attr decorator_list decorator_list Assign NameStore Dict Str Str
N/A N/A 
18. Using SQL reserved names

Need to use a reserved SQL name as a column name or table name? Need to include
a hyphen in a column or table name? No problem. Django quotes names
appropriately behind the scenes, so your database won't complain about
reserved-name usage.
 django.db models Thing N/A N/A models Model N/A N/A when N/A N/A models CharField max_length 1 primary_key True N/A join N/A N/A models CharField max_length 1 N/A like N/A N/A models CharField max_length 1 N/A drop N/A N/A models CharField max_length 1 N/A alter N/A N/A models CharField max_length 1 N/A having N/A N/A models CharField max_length 1 N/A where N/A N/A models DateField max_length 1 N/A has_hyphen N/A N/A models CharField max_length 1 db_column has-hyphen Meta N/A N/A N/A db_table select N/A __unicode__ N/A N/A self N/A N/A N/A N/A self when N/A N/A N/A __test__ N/A API_TESTS 
>>> import datetime
>>> day1 = datetime.date(2005, 1, 1)
>>> day2 = datetime.date(2006, 2, 2)
>>> t = Thing(when='a', join='b', like='c', drop='d', alter='e', having='f', where=day1, has_hyphen='h')
>>> t.save()
>>> print t.when
a

>>> u = Thing(when='h', join='i', like='j', drop='k', alter='l', having='m', where=day2)
>>> u.save()
>>> print u.when
h

>>> Thing.objects.order_by('when')
[<Thing: a>, <Thing: h>]
>>> v = Thing.objects.get(pk='a')
>>> print v.join
b
>>> print v.where
2005-01-01

>>> Thing.objects.dates('where', 'year')
[datetime.datetime(2005, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)]

>>> Thing.objects.filter(where__month=1)
[<Thing: a>]
