/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. """
  2. Regression for #9736.
  3. Checks some pathological column naming to make sure it doesn't break
  4. table creation or queries.
  5. """
  6. from django.db import models
  7. class Article(models.Model):
  8. Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
  9. headline = models.CharField(max_length=100)
  10. authors = models.ManyToManyField('Author', db_table='my m2m table')
  11. primary_author = models.ForeignKey('Author', db_column='Author ID', related_name='primary_set')
  12. def __unicode__(self):
  13. return self.headline
  14. class Meta:
  15. ordering = ('headline',)
  16. class Author(models.Model):
  17. Author_ID = models.AutoField(primary_key=True, db_column='Author ID')
  18. first_name = models.CharField(max_length=30, db_column='first name')
  19. last_name = models.CharField(max_length=30, db_column='last name')
  20. def __unicode__(self):
  21. return u'%s %s' % (self.first_name, self.last_name)
  22. class Meta:
  23. db_table = 'my author table'
  24. ordering = ('last_name','first_name')