2010-01-10 03:36:59 +00:00
|
|
|
from django.db import models
|
2012-07-20 12:48:51 +00:00
|
|
|
from django.utils import six
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2010-01-10 03:36:59 +00:00
|
|
|
|
2011-10-13 18:51:33 +00:00
|
|
|
|
2010-01-10 03:36:59 +00:00
|
|
|
class Article(models.Model):
|
|
|
|
"""
|
|
|
|
A simple Article model for testing
|
|
|
|
"""
|
2010-02-01 14:12:56 +00:00
|
|
|
site = models.ForeignKey('sites.Site', related_name="admin_articles")
|
2010-01-10 03:36:59 +00:00
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
title2 = models.CharField(max_length=100, verbose_name="another name")
|
|
|
|
created = models.DateTimeField()
|
|
|
|
|
|
|
|
def test_from_model(self):
|
|
|
|
return "nothing"
|
|
|
|
|
|
|
|
def test_from_model_with_override(self):
|
|
|
|
return "nothing"
|
2010-04-11 08:35:04 +00:00
|
|
|
test_from_model_with_override.short_description = "not What you Expect"
|
2010-02-26 13:17:43 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 13:17:43 +00:00
|
|
|
class Count(models.Model):
|
|
|
|
num = models.PositiveSmallIntegerField()
|
2010-11-09 16:46:42 +00:00
|
|
|
parent = models.ForeignKey('self', null=True)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2012-07-20 12:48:51 +00:00
|
|
|
return six.text_type(self.num)
|
2010-10-17 15:17:52 +00:00
|
|
|
|
|
|
|
class Event(models.Model):
|
|
|
|
date = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
|
|
class Location(models.Model):
|
|
|
|
event = models.OneToOneField(Event, verbose_name='awesome event')
|
|
|
|
|
|
|
|
class Guest(models.Model):
|
|
|
|
event = models.OneToOneField(Event)
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = "awesome guest"
|