2008-12-16 18:42:18 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-06-07 18:08:47 +02:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2009-12-22 19:29:00 +01:00
|
|
|
import datetime
|
2009-04-18 22:29:55 +02:00
|
|
|
import tempfile
|
|
|
|
import os
|
2009-12-22 19:29:00 +01:00
|
|
|
|
2010-08-06 16:58:05 +02:00
|
|
|
from django.contrib.auth.models import User
|
2014-01-22 07:43:33 +01:00
|
|
|
from django.contrib.contenttypes.fields import (
|
|
|
|
GenericForeignKey, GenericRelation
|
|
|
|
)
|
2010-02-26 14:17:43 +01:00
|
|
|
from django.contrib.contenttypes.models import ContentType
|
2011-10-13 20:51:33 +02:00
|
|
|
from django.core.files.storage import FileSystemStorage
|
|
|
|
from django.db import models
|
2012-08-12 12:32:08 +02:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-07-19 01:54:34 +02:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2008-07-19 01:54:34 +02:00
|
|
|
class Section(models.Model):
|
|
|
|
"""
|
2008-08-08 20:07:33 +02:00
|
|
|
A simple section that links to articles, to test linking to related items
|
2008-07-19 01:54:34 +02:00
|
|
|
in admin views.
|
|
|
|
"""
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-07-19 01:54:34 +02:00
|
|
|
class Article(models.Model):
|
|
|
|
"""
|
|
|
|
A simple article to test admin views. Test backwards compatibility.
|
|
|
|
"""
|
2008-08-08 20:07:33 +02:00
|
|
|
title = models.CharField(max_length=100)
|
2008-07-19 01:54:34 +02:00
|
|
|
content = models.TextField()
|
|
|
|
date = models.DateTimeField()
|
2010-03-16 20:01:40 +01:00
|
|
|
section = models.ForeignKey(Section, null=True, blank=True)
|
2008-07-19 01:54:34 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-08-08 20:07:33 +02:00
|
|
|
return self.title
|
2009-03-10 12:19:26 +01:00
|
|
|
|
2008-10-08 16:47:01 +02:00
|
|
|
def model_year(self):
|
|
|
|
return self.date.year
|
|
|
|
model_year.admin_order_field = 'date'
|
2010-03-16 17:10:27 +01:00
|
|
|
model_year.short_description = ''
|
2008-10-08 16:47:01 +02:00
|
|
|
|
2014-01-23 03:13:59 +01:00
|
|
|
def model_year_reversed(self):
|
|
|
|
return self.date.year
|
|
|
|
model_year_reversed.admin_order_field = '-date'
|
|
|
|
model_year_reversed.short_description = ''
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-16 16:04:47 +01:00
|
|
|
class Book(models.Model):
|
|
|
|
"""
|
|
|
|
A simple book that has chapters.
|
|
|
|
"""
|
2012-06-07 18:08:47 +02:00
|
|
|
name = models.CharField(max_length=100, verbose_name='¿Name?')
|
2008-12-16 18:42:18 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-12-16 18:42:18 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-16 18:42:18 +01:00
|
|
|
class Promo(models.Model):
|
2012-06-07 18:08:47 +02:00
|
|
|
name = models.CharField(max_length=100, verbose_name='¿Name?')
|
2008-12-16 18:42:18 +01:00
|
|
|
book = models.ForeignKey(Book)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-12-16 18:42:18 +01:00
|
|
|
return self.name
|
2008-12-16 16:04:47 +01:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-16 16:04:47 +01:00
|
|
|
class Chapter(models.Model):
|
2012-06-07 18:08:47 +02:00
|
|
|
title = models.CharField(max_length=100, verbose_name='¿Title?')
|
2008-12-16 16:04:47 +01:00
|
|
|
content = models.TextField()
|
|
|
|
book = models.ForeignKey(Book)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-12-16 16:04:47 +01:00
|
|
|
return self.title
|
|
|
|
|
2008-12-16 18:42:18 +01:00
|
|
|
class Meta:
|
2010-03-02 04:28:48 +01:00
|
|
|
# Use a utf-8 bytestring to ensure it works (see #11710)
|
|
|
|
verbose_name = '¿Chapter?'
|
2008-12-16 18:42:18 +01:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-16 18:42:18 +01:00
|
|
|
class ChapterXtra1(models.Model):
|
2012-06-07 18:08:47 +02:00
|
|
|
chap = models.OneToOneField(Chapter, verbose_name='¿Chap?')
|
|
|
|
xtra = models.CharField(max_length=100, verbose_name='¿Xtra?')
|
2008-12-16 18:42:18 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return '¿Xtra1: %s' % self.xtra
|
2008-12-16 18:42:18 +01:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-12-16 18:42:18 +01:00
|
|
|
class ChapterXtra2(models.Model):
|
2012-06-07 18:08:47 +02:00
|
|
|
chap = models.OneToOneField(Chapter, verbose_name='¿Chap?')
|
|
|
|
xtra = models.CharField(max_length=100, verbose_name='¿Xtra?')
|
2008-12-16 18:42:18 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return '¿Xtra2: %s' % self.xtra
|
2008-12-16 18:42:18 +01:00
|
|
|
|
2010-11-21 20:00:40 +01:00
|
|
|
|
2011-02-19 15:05:07 +01:00
|
|
|
class RowLevelChangePermissionModel(models.Model):
|
|
|
|
name = models.CharField(max_length=100, blank=True)
|
|
|
|
|
2010-11-21 20:00:40 +01:00
|
|
|
|
2008-07-19 01:54:34 +02:00
|
|
|
class CustomArticle(models.Model):
|
|
|
|
content = models.TextField()
|
|
|
|
date = models.DateTimeField()
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-07-19 01:54:34 +02:00
|
|
|
class ModelWithStringPrimaryKey(models.Model):
|
2012-06-07 17:34:25 +02:00
|
|
|
string_pk = models.CharField(max_length=255, primary_key=True)
|
2008-08-08 20:07:33 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 17:34:25 +02:00
|
|
|
return self.string_pk
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
2012-06-19 17:37:28 +02:00
|
|
|
return '/dummy/%s/' % self.string_pk
|
2008-08-08 20:07:33 +02:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-10-21 21:03:21 +02:00
|
|
|
class Color(models.Model):
|
|
|
|
value = models.CharField(max_length=10)
|
2013-08-11 22:19:09 +02:00
|
|
|
warm = models.BooleanField(default=False)
|
2013-10-22 12:21:07 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-10-21 21:03:21 +02:00
|
|
|
return self.value
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-02-09 19:59:05 +01:00
|
|
|
# we replicate Color to register with another ModelAdmin
|
|
|
|
class Color2(Color):
|
|
|
|
class Meta:
|
|
|
|
proxy = True
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2008-10-21 21:03:21 +02:00
|
|
|
class Thing(models.Model):
|
|
|
|
title = models.CharField(max_length=20)
|
|
|
|
color = models.ForeignKey(Color, limit_choices_to={'warm': True})
|
2012-09-16 01:20:56 +02:00
|
|
|
pub_date = models.DateField(blank=True, null=True)
|
2013-10-22 12:21:07 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2008-10-21 21:03:21 +02:00
|
|
|
return self.title
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2011-01-28 15:08:25 +01:00
|
|
|
class Actor(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
age = models.IntegerField()
|
2013-02-26 04:27:52 +01:00
|
|
|
title = models.CharField(max_length=50, null=True, blank=True)
|
2013-10-22 12:21:07 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2011-01-28 15:08:25 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2011-01-28 15:08:25 +01:00
|
|
|
class Inquisition(models.Model):
|
2013-08-11 22:19:09 +02:00
|
|
|
expected = models.BooleanField(default=False)
|
2011-01-28 15:08:25 +01:00
|
|
|
leader = models.ForeignKey(Actor)
|
2011-01-28 15:08:42 +01:00
|
|
|
country = models.CharField(max_length=20)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return "by %s from %s" % (self.leader, self.country)
|
2011-01-28 15:08:42 +01:00
|
|
|
|
2011-01-28 15:08:25 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2011-01-28 15:08:25 +01:00
|
|
|
class Sketch(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
inquisition = models.ForeignKey(Inquisition, limit_choices_to={'leader__name': 'Palin',
|
|
|
|
'leader__age': 27,
|
2011-01-28 15:08:42 +01:00
|
|
|
'expected': False,
|
2011-01-28 15:08:25 +01:00
|
|
|
})
|
2013-05-27 18:31:49 +02:00
|
|
|
defendant0 = models.ForeignKey(Actor, limit_choices_to={'title__isnull': False}, related_name='as_defendant0')
|
|
|
|
defendant1 = models.ForeignKey(Actor, limit_choices_to={'title__isnull': True}, related_name='as_defendant1')
|
2011-01-28 15:08:42 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2011-01-28 15:08:25 +01:00
|
|
|
return self.title
|
|
|
|
|
2011-01-28 15:08:42 +01:00
|
|
|
|
2014-02-01 20:23:31 +01:00
|
|
|
def today_callable_dict():
|
|
|
|
return {"last_action__gte": datetime.datetime.today()}
|
|
|
|
|
|
|
|
|
|
|
|
def today_callable_q():
|
|
|
|
return models.Q(last_action__gte=datetime.datetime.today())
|
|
|
|
|
|
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
|
|
class Character(models.Model):
|
|
|
|
username = models.CharField(max_length=100)
|
|
|
|
last_action = models.DateTimeField()
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.username
|
|
|
|
|
|
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
|
|
class StumpJoke(models.Model):
|
|
|
|
variation = models.CharField(max_length=100)
|
|
|
|
most_recently_fooled = models.ForeignKey(Character, limit_choices_to=today_callable_dict, related_name="+")
|
|
|
|
has_fooled_today = models.ManyToManyField(Character, limit_choices_to=today_callable_q, related_name="+")
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.variation
|
|
|
|
|
|
|
|
|
2009-04-01 16:14:20 +02:00
|
|
|
class Fabric(models.Model):
|
|
|
|
NG_CHOICES = (
|
|
|
|
('Textured', (
|
2013-10-20 01:33:10 +02:00
|
|
|
('x', 'Horizontal'),
|
|
|
|
('y', 'Vertical'),
|
|
|
|
)),
|
2009-04-01 16:14:20 +02:00
|
|
|
('plain', 'Smooth'),
|
|
|
|
)
|
|
|
|
surface = models.CharField(max_length=20, choices=NG_CHOICES)
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-03-17 21:51:47 +01:00
|
|
|
class Person(models.Model):
|
|
|
|
GENDER_CHOICES = (
|
|
|
|
(1, "Male"),
|
|
|
|
(2, "Female"),
|
|
|
|
)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
gender = models.IntegerField(choices=GENDER_CHOICES)
|
2011-01-03 14:56:31 +01:00
|
|
|
age = models.IntegerField(default=21)
|
2013-03-24 15:27:27 +01:00
|
|
|
alive = models.BooleanField(default=True)
|
2009-03-29 20:52:38 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-03-17 21:51:47 +01:00
|
|
|
return self.name
|
2009-03-29 20:52:38 +02:00
|
|
|
|
2010-02-16 13:17:37 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-03-10 12:19:26 +01:00
|
|
|
class Persona(models.Model):
|
|
|
|
"""
|
|
|
|
A simple persona associated with accounts, to test inlining of related
|
|
|
|
accounts which inherit from a common accounts class.
|
|
|
|
"""
|
2013-03-24 15:27:27 +01:00
|
|
|
name = models.CharField(blank=False, max_length=80)
|
2013-10-22 12:21:07 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-03-10 12:19:26 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-03-10 12:19:26 +01:00
|
|
|
class Account(models.Model):
|
|
|
|
"""
|
|
|
|
A simple, generic account encapsulating the information shared by all
|
|
|
|
types of accounts.
|
|
|
|
"""
|
2013-03-24 15:27:27 +01:00
|
|
|
username = models.CharField(blank=False, max_length=80)
|
2009-03-10 12:19:26 +01:00
|
|
|
persona = models.ForeignKey(Persona, related_name="accounts")
|
2012-06-07 18:08:47 +02:00
|
|
|
servicename = 'generic service'
|
2009-03-10 12:19:26 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-03-10 12:19:26 +01:00
|
|
|
return "%s: %s" % (self.servicename, self.username)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-03-10 12:19:26 +01:00
|
|
|
class FooAccount(Account):
|
|
|
|
"""A service-specific account of type Foo."""
|
2012-06-07 18:08:47 +02:00
|
|
|
servicename = 'foo'
|
2009-03-10 12:19:26 +01:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-03-10 12:19:26 +01:00
|
|
|
class BarAccount(Account):
|
|
|
|
"""A service-specific account of type Bar."""
|
2012-06-07 18:08:47 +02:00
|
|
|
servicename = 'bar'
|
2009-03-10 12:19:26 +01:00
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-03-23 21:22:56 +01:00
|
|
|
class Subscriber(models.Model):
|
|
|
|
name = models.CharField(blank=False, max_length=80)
|
|
|
|
email = models.EmailField(blank=False, max_length=175)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-03-23 21:22:56 +01:00
|
|
|
return "%s (%s)" % (self.name, self.email)
|
|
|
|
|
|
|
|
|
|
|
|
class ExternalSubscriber(Subscriber):
|
|
|
|
pass
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-04-06 22:23:33 +02:00
|
|
|
class OldSubscriber(Subscriber):
|
|
|
|
pass
|
|
|
|
|
2009-03-17 21:51:47 +01:00
|
|
|
|
2009-03-29 20:52:38 +02:00
|
|
|
class Media(models.Model):
|
|
|
|
name = models.CharField(max_length=60)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-03-29 20:52:38 +02:00
|
|
|
class Podcast(Media):
|
|
|
|
release_date = models.DateField()
|
|
|
|
|
2011-06-02 18:18:47 +02:00
|
|
|
class Meta:
|
2013-11-02 22:02:56 +01:00
|
|
|
ordering = ('release_date',) # overridden in PodcastAdmin
|
2011-06-02 18:18:47 +02:00
|
|
|
|
2009-03-29 20:52:38 +02:00
|
|
|
|
2009-04-18 23:03:29 +02:00
|
|
|
class Vodcast(Media):
|
|
|
|
media = models.OneToOneField(Media, primary_key=True, parent_link=True)
|
|
|
|
released = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
|
2009-03-31 02:03:34 +02:00
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=128)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-03-31 02:03:34 +02:00
|
|
|
class Child(models.Model):
|
|
|
|
parent = models.ForeignKey(Parent, editable=False)
|
|
|
|
name = models.CharField(max_length=30, blank=True)
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-04-01 05:11:58 +02:00
|
|
|
class EmptyModel(models.Model):
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-04-01 05:11:58 +02:00
|
|
|
return "Primary key = %s" % self.id
|
|
|
|
|
2009-04-06 22:23:33 +02:00
|
|
|
|
2011-11-13 20:05:02 +01:00
|
|
|
temp_storage = FileSystemStorage(tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']))
|
2009-04-18 22:29:55 +02:00
|
|
|
UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-04-18 22:29:55 +02:00
|
|
|
class Gallery(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-04-18 22:29:55 +02:00
|
|
|
class Picture(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
image = models.FileField(storage=temp_storage, upload_to='test_upload')
|
|
|
|
gallery = models.ForeignKey(Gallery, related_name="pictures")
|
|
|
|
|
|
|
|
|
2009-05-07 13:56:10 +02:00
|
|
|
class Language(models.Model):
|
|
|
|
iso = models.CharField(max_length=5, primary_key=True)
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
english_name = models.CharField(max_length=50)
|
|
|
|
shortlist = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('iso',)
|
|
|
|
|
|
|
|
|
2009-05-07 14:52:43 +02:00
|
|
|
# a base class for Recommender and Recommendation
|
|
|
|
class Title(models.Model):
|
|
|
|
pass
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-07 14:52:43 +02:00
|
|
|
class TitleTranslation(models.Model):
|
|
|
|
title = models.ForeignKey(Title)
|
|
|
|
text = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-07 14:52:43 +02:00
|
|
|
class Recommender(Title):
|
|
|
|
pass
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-07 14:52:43 +02:00
|
|
|
class Recommendation(Title):
|
|
|
|
recommender = models.ForeignKey(Recommender)
|
|
|
|
|
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class Collector(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class Widget(models.Model):
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class DooHickey(models.Model):
|
|
|
|
code = models.CharField(max_length=10, primary_key=True)
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class Grommet(models.Model):
|
|
|
|
code = models.AutoField(primary_key=True)
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class Whatsit(models.Model):
|
|
|
|
index = models.IntegerField(primary_key=True)
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class Doodad(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2009-05-09 13:40:13 +02:00
|
|
|
class FancyDoodad(Doodad):
|
|
|
|
owner = models.ForeignKey(Collector)
|
|
|
|
expensive = models.BooleanField(default=True)
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-07-03 05:05:17 +02:00
|
|
|
class Category(models.Model):
|
|
|
|
collector = models.ForeignKey(Collector)
|
|
|
|
order = models.PositiveIntegerField()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('order',)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-06-07 18:08:47 +02:00
|
|
|
return '%s:o%s' % (self.id, self.order)
|
2009-07-03 05:05:17 +02:00
|
|
|
|
2009-12-22 19:29:00 +01:00
|
|
|
|
|
|
|
class Link(models.Model):
|
|
|
|
posted = models.DateField(
|
|
|
|
default=lambda: datetime.date.today() - datetime.timedelta(days=7)
|
|
|
|
)
|
|
|
|
url = models.URLField()
|
|
|
|
post = models.ForeignKey("Post")
|
|
|
|
|
|
|
|
|
2011-04-22 14:02:25 +02:00
|
|
|
class PrePopulatedPost(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
2013-08-11 22:19:09 +02:00
|
|
|
published = models.BooleanField(default=False)
|
2011-04-22 14:02:25 +02:00
|
|
|
slug = models.SlugField()
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2011-04-22 14:02:25 +02:00
|
|
|
class PrePopulatedSubPost(models.Model):
|
|
|
|
post = models.ForeignKey(PrePopulatedPost)
|
|
|
|
subtitle = models.CharField(max_length=100)
|
|
|
|
subslug = models.SlugField()
|
|
|
|
|
|
|
|
|
2009-12-22 19:29:00 +01:00
|
|
|
class Post(models.Model):
|
2011-02-19 13:55:09 +01:00
|
|
|
title = models.CharField(max_length=100, help_text="Some help text for the title (with unicode ŠĐĆŽćžšđ)")
|
|
|
|
content = models.TextField(help_text="Some help text for the content (with unicode ŠĐĆŽćžšđ)")
|
|
|
|
posted = models.DateField(
|
2013-10-20 01:33:10 +02:00
|
|
|
default=datetime.date.today,
|
|
|
|
help_text="Some help text for the date (with unicode ŠĐĆŽćžšđ)"
|
2011-02-19 13:55:09 +01:00
|
|
|
)
|
2010-03-10 09:37:17 +01:00
|
|
|
public = models.NullBooleanField()
|
2009-12-22 19:29:00 +01:00
|
|
|
|
|
|
|
def awesomeness_level(self):
|
|
|
|
return "Very awesome."
|
|
|
|
|
2009-05-07 14:52:43 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2009-12-18 11:08:05 +01:00
|
|
|
class Gadget(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2009-12-18 11:08:05 +01:00
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class Villain(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2010-02-26 14:17:43 +01:00
|
|
|
class SuperVillain(Villain):
|
|
|
|
pass
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class FunkyTag(models.Model):
|
|
|
|
"Because we all know there's only one real use case for GFKs."
|
|
|
|
name = models.CharField(max_length=25)
|
|
|
|
content_type = models.ForeignKey(ContentType)
|
|
|
|
object_id = models.PositiveIntegerField()
|
2014-01-22 07:43:33 +01:00
|
|
|
content_object = GenericForeignKey('content_type', 'object_id')
|
2010-02-26 14:17:43 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class Plot(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
team_leader = models.ForeignKey(Villain, related_name='lead_plots')
|
|
|
|
contact = models.ForeignKey(Villain, related_name='contact_plots')
|
2014-01-22 07:43:33 +01:00
|
|
|
tags = GenericRelation(FunkyTag)
|
2010-02-26 14:17:43 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class PlotDetails(models.Model):
|
|
|
|
details = models.CharField(max_length=100)
|
|
|
|
plot = models.OneToOneField(Plot)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.details
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class SecretHideout(models.Model):
|
|
|
|
""" Secret! Not registered with the admin! """
|
|
|
|
location = models.CharField(max_length=100)
|
|
|
|
villain = models.ForeignKey(Villain)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.location
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class SuperSecretHideout(models.Model):
|
|
|
|
""" Secret! Not registered with the admin! """
|
|
|
|
location = models.CharField(max_length=100)
|
|
|
|
supervillain = models.ForeignKey(SuperVillain)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.location
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class CyclicOne(models.Model):
|
|
|
|
name = models.CharField(max_length=25)
|
|
|
|
two = models.ForeignKey('CyclicTwo')
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-02-26 14:17:43 +01:00
|
|
|
class CyclicTwo(models.Model):
|
|
|
|
name = models.CharField(max_length=25)
|
|
|
|
one = models.ForeignKey(CyclicOne)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-02-26 14:17:43 +01:00
|
|
|
return self.name
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2010-03-21 15:23:25 +01:00
|
|
|
class Topping(models.Model):
|
2010-04-11 10:35:04 +02:00
|
|
|
name = models.CharField(max_length=20)
|
2010-03-21 15:23:25 +01:00
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2010-03-21 15:23:25 +01:00
|
|
|
class Pizza(models.Model):
|
|
|
|
name = models.CharField(max_length=20)
|
2013-08-29 15:39:31 +02:00
|
|
|
toppings = models.ManyToManyField('Topping', related_name='pizzas')
|
2010-03-21 15:23:25 +01:00
|
|
|
|
|
|
|
|
2010-08-06 16:58:05 +02:00
|
|
|
class Album(models.Model):
|
|
|
|
owner = models.ForeignKey(User)
|
|
|
|
title = models.CharField(max_length=30)
|
|
|
|
|
2010-12-23 04:44:38 +01:00
|
|
|
|
2011-01-13 00:30:47 +01:00
|
|
|
class Employee(Person):
|
|
|
|
code = models.CharField(max_length=20)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2011-01-13 00:30:47 +01:00
|
|
|
class WorkHour(models.Model):
|
|
|
|
datum = models.DateField()
|
|
|
|
employee = models.ForeignKey(Employee)
|
|
|
|
|
|
|
|
|
2011-01-20 01:33:32 +01:00
|
|
|
class Question(models.Model):
|
|
|
|
question = models.CharField(max_length=20)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2011-01-20 01:33:32 +01:00
|
|
|
class Answer(models.Model):
|
|
|
|
question = models.ForeignKey(Question, on_delete=models.PROTECT)
|
|
|
|
answer = models.CharField(max_length=20)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2011-01-20 01:33:32 +01:00
|
|
|
return self.answer
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2011-02-08 13:00:21 +01:00
|
|
|
class Reservation(models.Model):
|
|
|
|
start_date = models.DateTimeField()
|
|
|
|
price = models.IntegerField()
|
2011-02-19 12:48:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
DRIVER_CHOICES = (
|
2012-06-07 18:08:47 +02:00
|
|
|
('bill', 'Bill G'),
|
|
|
|
('steve', 'Steve J'),
|
2011-02-19 12:48:42 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
RESTAURANT_CHOICES = (
|
2012-06-07 18:08:47 +02:00
|
|
|
('indian', 'A Taste of India'),
|
|
|
|
('thai', 'Thai Pography'),
|
|
|
|
('pizza', 'Pizza Mama'),
|
2011-02-19 12:48:42 +01:00
|
|
|
)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2011-02-19 12:48:42 +01:00
|
|
|
class FoodDelivery(models.Model):
|
|
|
|
reference = models.CharField(max_length=100)
|
|
|
|
driver = models.CharField(max_length=100, choices=DRIVER_CHOICES, blank=True)
|
|
|
|
restaurant = models.CharField(max_length=100, choices=RESTAURANT_CHOICES, blank=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = (("driver", "restaurant"),)
|
|
|
|
|
|
|
|
|
2012-12-24 20:17:16 +01:00
|
|
|
@python_2_unicode_compatible
|
|
|
|
class CoverLetter(models.Model):
|
|
|
|
author = models.CharField(max_length=30)
|
|
|
|
date_written = models.DateField(null=True, blank=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.author
|
|
|
|
|
|
|
|
|
2011-02-21 00:09:25 +01:00
|
|
|
class Paper(models.Model):
|
|
|
|
title = models.CharField(max_length=30)
|
|
|
|
author = models.CharField(max_length=30, blank=True, null=True)
|
|
|
|
|
2011-09-20 20:16:49 +02:00
|
|
|
|
2012-12-24 20:17:16 +01:00
|
|
|
class ShortMessage(models.Model):
|
|
|
|
content = models.CharField(max_length=140)
|
|
|
|
timestamp = models.DateTimeField(null=True, blank=True)
|
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2012-12-24 20:17:16 +01:00
|
|
|
class Telegram(models.Model):
|
|
|
|
title = models.CharField(max_length=30)
|
|
|
|
date_sent = models.DateField(null=True, blank=True)
|
2011-02-21 00:09:25 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2012-12-24 20:17:16 +01:00
|
|
|
return self.title
|
2011-02-21 00:09:25 +01:00
|
|
|
|
|
|
|
|
2011-03-03 14:20:45 +01:00
|
|
|
class Story(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
content = models.TextField()
|
|
|
|
|
|
|
|
|
|
|
|
class OtherStory(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
content = models.TextField()
|
|
|
|
|
2011-02-19 12:48:42 +01:00
|
|
|
|
2011-06-03 13:54:29 +02:00
|
|
|
class ComplexSortedPerson(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
age = models.PositiveIntegerField()
|
|
|
|
is_employee = models.NullBooleanField()
|
|
|
|
|
2013-05-19 10:52:29 +02:00
|
|
|
|
|
|
|
class PluggableSearchPerson(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
age = models.PositiveIntegerField()
|
|
|
|
|
|
|
|
|
2011-11-22 10:14:09 +01:00
|
|
|
class PrePopulatedPostLargeSlug(models.Model):
|
|
|
|
"""
|
|
|
|
Regression test for #15938: a large max_length for the slugfield must not
|
|
|
|
be localized in prepopulated_fields_js.html or it might end up breaking
|
|
|
|
the javascript (ie, using THOUSAND_SEPARATOR ends up with maxLength=1,000)
|
|
|
|
"""
|
|
|
|
title = models.CharField(max_length=100)
|
2013-08-11 22:19:09 +02:00
|
|
|
published = models.BooleanField(default=False)
|
2011-10-26 07:33:17 +02:00
|
|
|
slug = models.SlugField(max_length=1000)
|
2011-11-22 10:14:09 +01:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2011-11-22 10:14:09 +01:00
|
|
|
class AdminOrderedField(models.Model):
|
|
|
|
order = models.IntegerField()
|
|
|
|
stuff = models.CharField(max_length=200)
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2011-11-22 10:14:09 +01:00
|
|
|
class AdminOrderedModelMethod(models.Model):
|
|
|
|
order = models.IntegerField()
|
|
|
|
stuff = models.CharField(max_length=200)
|
2013-10-22 12:21:07 +02:00
|
|
|
|
2011-11-22 10:14:09 +01:00
|
|
|
def some_order(self):
|
|
|
|
return self.order
|
|
|
|
some_order.admin_order_field = 'order'
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2011-11-22 10:14:09 +01:00
|
|
|
class AdminOrderedAdminMethod(models.Model):
|
|
|
|
order = models.IntegerField()
|
|
|
|
stuff = models.CharField(max_length=200)
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2011-11-22 10:14:09 +01:00
|
|
|
class AdminOrderedCallable(models.Model):
|
|
|
|
order = models.IntegerField()
|
|
|
|
stuff = models.CharField(max_length=200)
|
2011-12-19 15:59:14 +01:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2011-12-19 15:59:14 +01:00
|
|
|
class Report(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2011-12-19 15:59:14 +01:00
|
|
|
return self.title
|
2012-02-19 17:42:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MainPrepopulated(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
pubdate = models.DateField()
|
|
|
|
status = models.CharField(
|
|
|
|
max_length=20,
|
|
|
|
choices=(('option one', 'Option One'),
|
|
|
|
('option two', 'Option Two')))
|
2013-07-30 09:21:08 +02:00
|
|
|
slug1 = models.SlugField(blank=True)
|
|
|
|
slug2 = models.SlugField(blank=True)
|
2012-02-19 17:42:12 +01:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-02-19 17:42:12 +01:00
|
|
|
class RelatedPrepopulated(models.Model):
|
|
|
|
parent = models.ForeignKey(MainPrepopulated)
|
|
|
|
name = models.CharField(max_length=75)
|
|
|
|
pubdate = models.DateField()
|
|
|
|
status = models.CharField(
|
|
|
|
max_length=20,
|
|
|
|
choices=(('option one', 'Option One'),
|
|
|
|
('option two', 'Option Two')))
|
|
|
|
slug1 = models.SlugField(max_length=50)
|
2012-03-03 03:13:35 +01:00
|
|
|
slug2 = models.SlugField(max_length=60)
|
|
|
|
|
|
|
|
|
|
|
|
class UnorderedObject(models.Model):
|
|
|
|
"""
|
|
|
|
Model without any defined `Meta.ordering`.
|
|
|
|
Refs #16819.
|
|
|
|
"""
|
|
|
|
name = models.CharField(max_length=255)
|
|
|
|
bool = models.BooleanField(default=True)
|
2012-07-22 03:10:24 +02:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-07-22 03:10:24 +02:00
|
|
|
class UndeletableObject(models.Model):
|
|
|
|
"""
|
|
|
|
Model whose show_delete in admin change_view has been disabled
|
|
|
|
Refs #10057.
|
|
|
|
"""
|
|
|
|
name = models.CharField(max_length=255)
|
2012-09-08 17:18:08 +02:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-08-18 00:05:13 +02:00
|
|
|
class UnchangeableObject(models.Model):
|
|
|
|
"""
|
|
|
|
Model whose change_view is disabled in admin
|
|
|
|
Refs #20640.
|
|
|
|
"""
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-11-17 22:53:31 +01:00
|
|
|
class UserMessenger(models.Model):
|
|
|
|
"""
|
|
|
|
Dummy class for testing message_user functions on ModelAdmin
|
|
|
|
"""
|
2012-09-08 17:18:08 +02:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-09-08 17:18:08 +02:00
|
|
|
class Simple(models.Model):
|
|
|
|
"""
|
|
|
|
Simple model with nothing on it for use in testing
|
|
|
|
"""
|
2012-11-25 23:13:22 +01:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-11-25 23:13:22 +01:00
|
|
|
class Choice(models.Model):
|
2012-12-04 21:49:02 +01:00
|
|
|
choice = models.IntegerField(blank=True, null=True,
|
|
|
|
choices=((1, 'Yes'), (0, 'No'), (None, 'No opinion')))
|
2013-09-06 22:28:48 +02:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-11-15 03:26:19 +01:00
|
|
|
class ParentWithDependentChildren(models.Model):
|
|
|
|
"""
|
|
|
|
Issue #20522
|
|
|
|
Model where the validation of child foreign-key relationships depends
|
|
|
|
on validation of the parent
|
|
|
|
"""
|
|
|
|
some_required_info = models.PositiveIntegerField()
|
|
|
|
family_name = models.CharField(max_length=255, blank=False)
|
|
|
|
|
|
|
|
|
|
|
|
class DependentChild(models.Model):
|
|
|
|
"""
|
|
|
|
Issue #20522
|
|
|
|
Model that depends on validation of the parent class for one of its
|
|
|
|
fields to validate during clean
|
|
|
|
"""
|
|
|
|
parent = models.ForeignKey(ParentWithDependentChildren)
|
|
|
|
family_name = models.CharField(max_length=255)
|
|
|
|
|
|
|
|
|
2013-09-06 22:28:48 +02:00
|
|
|
class _Manager(models.Manager):
|
|
|
|
def get_queryset(self):
|
|
|
|
return super(_Manager, self).get_queryset().filter(pk__gt=1)
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-09-06 22:28:48 +02:00
|
|
|
class FilteredManager(models.Model):
|
|
|
|
def __str__(self):
|
|
|
|
return "PK=%d" % self.pk
|
|
|
|
|
|
|
|
pk_gt_1 = _Manager()
|
|
|
|
objects = models.Manager()
|
2013-02-23 18:57:48 +01:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-02-23 18:57:48 +01:00
|
|
|
class EmptyModelVisible(models.Model):
|
|
|
|
""" See ticket #11277. """
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-02-23 18:57:48 +01:00
|
|
|
class EmptyModelHidden(models.Model):
|
|
|
|
""" See ticket #11277. """
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-02-23 18:57:48 +01:00
|
|
|
class EmptyModelMixin(models.Model):
|
|
|
|
""" See ticket #11277. """
|
2013-10-24 17:28:09 +02:00
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-10-24 17:28:09 +02:00
|
|
|
class State(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-10-24 17:28:09 +02:00
|
|
|
class City(models.Model):
|
|
|
|
state = models.ForeignKey(State)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-21 10:26:49 +01:00
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/dummy/%s/' % self.pk
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-10-24 17:28:09 +02:00
|
|
|
class Restaurant(models.Model):
|
|
|
|
city = models.ForeignKey(City)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
2013-11-21 10:26:49 +01:00
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/dummy/%s/' % self.pk
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2013-10-24 17:28:09 +02:00
|
|
|
class Worker(models.Model):
|
|
|
|
work_at = models.ForeignKey(Restaurant)
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
surname = models.CharField(max_length=50)
|