parts/django/tests/modeltests/reserved_names/models.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 """
       
     2 18. Using SQL reserved names
       
     3 
       
     4 Need to use a reserved SQL name as a column name or table name? Need to include
       
     5 a hyphen in a column or table name? No problem. Django quotes names
       
     6 appropriately behind the scenes, so your database won't complain about
       
     7 reserved-name usage.
       
     8 """
       
     9 
       
    10 from django.db import models
       
    11 
       
    12 class Thing(models.Model):
       
    13     when = models.CharField(max_length=1, primary_key=True)
       
    14     join = models.CharField(max_length=1)
       
    15     like = models.CharField(max_length=1)
       
    16     drop = models.CharField(max_length=1)
       
    17     alter = models.CharField(max_length=1)
       
    18     having = models.CharField(max_length=1)
       
    19     where = models.DateField(max_length=1)
       
    20     has_hyphen = models.CharField(max_length=1, db_column='has-hyphen')
       
    21     class Meta:
       
    22        db_table = 'select'
       
    23 
       
    24     def __unicode__(self):
       
    25         return self.when