2009-05-03 21:38:36 +08:00
|
|
|
"""
|
|
|
|
Testing of admin inline formsets.
|
|
|
|
|
|
|
|
"""
|
2012-06-08 00:08:47 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2009-05-03 21:38:36 +08:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
from django.contrib.contenttypes import generic
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2009-05-03 21:38:36 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-05-03 21:38:36 +08:00
|
|
|
class Parent(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2009-05-03 21:38:36 +08:00
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-05-03 21:38:36 +08:00
|
|
|
class Teacher(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2009-05-03 21:38:36 +08:00
|
|
|
return self.name
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2009-05-03 21:38:36 +08:00
|
|
|
class Child(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
teacher = models.ForeignKey(Teacher)
|
|
|
|
|
|
|
|
content_type = models.ForeignKey(ContentType)
|
|
|
|
object_id = models.PositiveIntegerField()
|
|
|
|
parent = generic.GenericForeignKey()
|
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2012-06-08 00:08:47 +08:00
|
|
|
return 'I am %s, a child of %s' % (self.name, self.parent)
|
2009-05-03 21:38:36 +08:00
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-04-27 20:35:49 +08:00
|
|
|
class Book(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
2011-09-21 02:16:49 +08:00
|
|
|
|
2010-04-27 20:35:49 +08:00
|
|
|
class Author(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
books = models.ManyToManyField(Book)
|
|
|
|
|
2010-02-24 01:14:50 +08:00
|
|
|
|
|
|
|
class Holder(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
class Inner(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
holder = models.ForeignKey(Holder)
|
2010-03-27 07:38:05 +08:00
|
|
|
readonly = models.CharField("Inner readonly label", max_length=1)
|
2010-02-24 01:14:50 +08:00
|
|
|
|
|
|
|
|
2010-03-21 09:54:00 +08:00
|
|
|
class Holder2(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
class Inner2(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
holder = models.ForeignKey(Holder2)
|
|
|
|
|
|
|
|
class Holder3(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
|
|
|
|
|
|
|
|
class Inner3(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
holder = models.ForeignKey(Holder3)
|
|
|
|
|
2011-08-17 22:12:25 +08:00
|
|
|
# Models for ticket #8190
|
|
|
|
|
|
|
|
class Holder4(models.Model):
|
|
|
|
dummy = models.IntegerField()
|
|
|
|
|
|
|
|
class Inner4Stacked(models.Model):
|
|
|
|
dummy = models.IntegerField(help_text="Awesome stacked help text is awesome.")
|
|
|
|
holder = models.ForeignKey(Holder4)
|
|
|
|
|
|
|
|
class Inner4Tabular(models.Model):
|
|
|
|
dummy = models.IntegerField(help_text="Awesome tabular help text is awesome.")
|
|
|
|
holder = models.ForeignKey(Holder4)
|
|
|
|
|
|
|
|
|
2010-04-27 23:05:38 +08:00
|
|
|
# Models for #12749
|
|
|
|
|
|
|
|
class Person(models.Model):
|
|
|
|
firstname = models.CharField(max_length=15)
|
|
|
|
|
|
|
|
class OutfitItem(models.Model):
|
|
|
|
name = models.CharField(max_length=15)
|
|
|
|
|
|
|
|
class Fashionista(models.Model):
|
|
|
|
person = models.OneToOneField(Person, primary_key=True)
|
|
|
|
weaknesses = models.ManyToManyField(OutfitItem, through='ShoppingWeakness', blank=True)
|
|
|
|
|
|
|
|
class ShoppingWeakness(models.Model):
|
|
|
|
fashionista = models.ForeignKey(Fashionista)
|
|
|
|
item = models.ForeignKey(OutfitItem)
|
|
|
|
|
2011-02-22 11:07:57 +08:00
|
|
|
# Models for #13510
|
|
|
|
|
|
|
|
class TitleCollection(models.Model):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Title(models.Model):
|
|
|
|
collection = models.ForeignKey(TitleCollection, blank=True, null=True)
|
|
|
|
title1 = models.CharField(max_length=100)
|
|
|
|
title2 = models.CharField(max_length=100)
|
|
|
|
|
2011-02-26 09:44:41 +08:00
|
|
|
# Models for #15424
|
|
|
|
|
|
|
|
class Poll(models.Model):
|
|
|
|
name = models.CharField(max_length=40)
|
|
|
|
|
|
|
|
class Question(models.Model):
|
|
|
|
poll = models.ForeignKey(Poll)
|
|
|
|
|
|
|
|
class Novel(models.Model):
|
|
|
|
name = models.CharField(max_length=40)
|
|
|
|
|
|
|
|
class Chapter(models.Model):
|
|
|
|
novel = models.ForeignKey(Novel)
|
|
|
|
|
2011-09-21 22:00:58 +08:00
|
|
|
|
|
|
|
# Models for #16838
|
|
|
|
class CapoFamiglia(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
|
|
|
|
class Consigliere(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
capo_famiglia = models.ForeignKey(CapoFamiglia, related_name='+')
|
|
|
|
|
|
|
|
|
|
|
|
class SottoCapo(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
capo_famiglia = models.ForeignKey(CapoFamiglia, related_name='+')
|
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-22 16:33:58 +08:00
|
|
|
|
2012-06-08 01:52:13 +08:00
|
|
|
# Models for #18433
|
|
|
|
|
|
|
|
class ParentModelWithCustomPk(models.Model):
|
|
|
|
my_own_pk = models.CharField(max_length=100, primary_key=True)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
|
|
|
|
class ChildModel1(models.Model):
|
|
|
|
my_own_pk = models.CharField(max_length=100, primary_key=True)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
parent = models.ForeignKey(ParentModelWithCustomPk)
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/child_model1/'
|
|
|
|
|
|
|
|
|
|
|
|
class ChildModel2(models.Model):
|
|
|
|
my_own_pk = models.CharField(max_length=100, primary_key=True)
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
parent = models.ForeignKey(ParentModelWithCustomPk)
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/child_model2/'
|
|
|
|
|
|
|
|
|
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-22 16:33:58 +08:00
|
|
|
# Other models
|
|
|
|
|
|
|
|
class ProfileCollection(models.Model):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Profile(models.Model):
|
|
|
|
collection = models.ForeignKey(ProfileCollection, blank=True, null=True)
|
|
|
|
first_name = models.CharField(max_length=100)
|
2012-06-08 00:08:47 +08:00
|
|
|
last_name = models.CharField(max_length=100)
|