PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/custom_columns_regress/models.py

https://code.google.com/p/mango-py/
Python | 36 lines | 27 code | 1 blank | 8 comment | 1 complexity | b6c1c0d27ed759a3ebef486b5099198e MD5 | raw file
 1"""
 2Regression for #9736.
 3
 4Checks some pathological column naming to make sure it doesn't break
 5table creation or queries.
 6
 7"""
 8
 9from django.db import models
10
11class Article(models.Model):
12    Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
13    headline = models.CharField(max_length=100)
14    authors = models.ManyToManyField('Author', db_table='my m2m table')
15    primary_author = models.ForeignKey('Author', db_column='Author ID', related_name='primary_set')
16
17    def __unicode__(self):
18        return self.headline
19
20    class Meta:
21        ordering = ('headline',)
22
23class Author(models.Model):
24    Author_ID = models.AutoField(primary_key=True, db_column='Author ID')
25    first_name = models.CharField(max_length=30, db_column='first name')
26    last_name = models.CharField(max_length=30, db_column='last name')
27
28    def __unicode__(self):
29        return u'%s %s' % (self.first_name, self.last_name)
30
31    class Meta:
32        db_table = 'my author table'
33        ordering = ('last_name','first_name')
34
35
36