~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to tests/regressiontests/admin_inlines/models.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone, Jakub Wilk, Luke Faraone
  • Date: 2013-05-09 15:10:47 UTC
  • mfrom: (1.1.21) (4.4.27 sid)
  • Revision ID: package-import@ubuntu.com-20130509151047-aqv8d71oj9wvcv8c
Tags: 1.5.1-2
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Luke Faraone ]
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Testing of admin inline formsets.
3
3
 
4
4
"""
 
5
from __future__ import unicode_literals
 
6
 
5
7
from django.db import models
6
8
from django.contrib.contenttypes.models import ContentType
7
9
from django.contrib.contenttypes import generic
8
 
 
9
 
 
 
10
from django.utils.encoding import python_2_unicode_compatible
 
11
 
 
12
 
 
13
@python_2_unicode_compatible
10
14
class Parent(models.Model):
11
15
    name = models.CharField(max_length=50)
12
16
 
13
 
    def __unicode__(self):
 
17
    def __str__(self):
14
18
        return self.name
15
19
 
16
20
 
 
21
@python_2_unicode_compatible
17
22
class Teacher(models.Model):
18
23
    name = models.CharField(max_length=50)
19
24
 
20
 
    def __unicode__(self):
 
25
    def __str__(self):
21
26
        return self.name
22
27
 
23
28
 
 
29
@python_2_unicode_compatible
24
30
class Child(models.Model):
25
31
    name = models.CharField(max_length=50)
26
32
    teacher = models.ForeignKey(Teacher)
29
35
    object_id = models.PositiveIntegerField()
30
36
    parent = generic.GenericForeignKey()
31
37
 
32
 
    def __unicode__(self):
33
 
        return u'I am %s, a child of %s' % (self.name, self.parent)
 
38
    def __str__(self):
 
39
        return 'I am %s, a child of %s' % (self.name, self.parent)
34
40
 
35
41
 
36
42
class Book(models.Model):
51
57
    holder = models.ForeignKey(Holder)
52
58
    readonly = models.CharField("Inner readonly label", max_length=1)
53
59
 
 
60
    def get_absolute_url(self):
 
61
        return '/inner/'
 
62
 
54
63
 
55
64
class Holder2(models.Model):
56
65
    dummy = models.IntegerField()
81
90
    dummy = models.IntegerField(help_text="Awesome tabular help text is awesome.")
82
91
    holder = models.ForeignKey(Holder4)
83
92
 
84
 
 
85
93
# Models for #12749
86
94
 
87
95
class Person(models.Model):
124
132
 
125
133
 
126
134
# Models for #16838
 
135
 
127
136
class CapoFamiglia(models.Model):
128
137
    name = models.CharField(max_length=100)
129
138
 
137
146
    name = models.CharField(max_length=100)
138
147
    capo_famiglia = models.ForeignKey(CapoFamiglia, related_name='+')
139
148
 
 
149
# Models for #18433
 
150
 
 
151
class ParentModelWithCustomPk(models.Model):
 
152
    my_own_pk = models.CharField(max_length=100, primary_key=True)
 
153
    name = models.CharField(max_length=100)
 
154
 
 
155
 
 
156
class ChildModel1(models.Model):
 
157
    my_own_pk = models.CharField(max_length=100, primary_key=True)
 
158
    name = models.CharField(max_length=100)
 
159
    parent = models.ForeignKey(ParentModelWithCustomPk)
 
160
 
 
161
    def get_absolute_url(self):
 
162
        return '/child_model1/'
 
163
 
 
164
 
 
165
class ChildModel2(models.Model):
 
166
    my_own_pk = models.CharField(max_length=100, primary_key=True)
 
167
    name = models.CharField(max_length=100)
 
168
    parent = models.ForeignKey(ParentModelWithCustomPk)
 
169
 
 
170
    def get_absolute_url(self):
 
171
        return '/child_model2/'
 
172
 
 
173
# Models for #19524
 
174
 
 
175
class LifeForm(models.Model):
 
176
    pass
 
177
 
 
178
class ExtraTerrestrial(LifeForm):
 
179
    name = models.CharField(max_length=100)
 
180
 
 
181
class Sighting(models.Model):
 
182
    et = models.ForeignKey(ExtraTerrestrial)
 
183
    place = models.CharField(max_length=100)
 
184
 
140
185
# Other models
141
186
 
142
187
class ProfileCollection(models.Model):
145
190
class Profile(models.Model):
146
191
    collection = models.ForeignKey(ProfileCollection, blank=True, null=True)
147
192
    first_name = models.CharField(max_length=100)
148
 
    last_name = models.CharField(max_length=100)
 
 
b'\\ No newline at end of file'
 
193
    last_name = models.CharField(max_length=100)