2008-12-02 14:23:29 +01:00
|
|
|
"""
|
|
|
|
Regression for #9736.
|
|
|
|
|
|
|
|
Checks some pathological column naming to make sure it doesn't break
|
|
|
|
table creation or queries.
|
|
|
|
|
|
|
|
"""
|
2012-06-07 18:08:47 +02:00
|
|
|
from __future__ import unicode_literals
|
2008-12-02 14:23:29 +01:00
|
|
|
|
|
|
|
from django.db import models
|
2012-08-12 12:32:08 +02:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-12-02 14:23:29 +01:00
|
|
|
|
2011-10-13 20:51:33 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-02 14:23:29 +01:00
|
|
|
class Article(models.Model):
|
|
|
|
Article_ID = models.AutoField(primary_key=True, db_column='Article ID')
|
|
|
|
headline = models.CharField(max_length=100)
|
|
|
|
authors = models.ManyToManyField('Author', db_table='my m2m table')
|
|
|
|
primary_author = models.ForeignKey('Author', db_column='Author ID', related_name='primary_set')
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-12-02 14:23:29 +01:00
|
|
|
return self.headline
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('headline',)
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-02 14:23:29 +01:00
|
|
|
class Author(models.Model):
|
|
|
|
Author_ID = models.AutoField(primary_key=True, db_column='Author ID')
|
|
|
|
first_name = models.CharField(max_length=30, db_column='first name')
|
|
|
|
last_name = models.CharField(max_length=30, db_column='last name')
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return '%s %s' % (self.first_name, self.last_name)
|
2008-12-02 14:23:29 +01:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
db_table = 'my author table'
|
2013-10-26 21:15:03 +02:00
|
|
|
ordering = ('last_name', 'first_name')
|