1
# -*- coding: utf-8 -*-
2
from __future__ import unicode_literals
4
from django.db import models
5
from django.utils.encoding import python_2_unicode_compatible
8
@python_2_unicode_compatible
9
class Foo(models.Model):
10
name = models.CharField(max_length=50)
11
friend = models.CharField(max_length=50, blank=True)
14
return "Foo %s" % self.name
16
@python_2_unicode_compatible
17
class Bar(models.Model):
18
name = models.CharField(max_length=50)
19
normal = models.ForeignKey(Foo, related_name='normal_foo')
20
fwd = models.ForeignKey("Whiz")
21
back = models.ForeignKey("Foo")
24
return "Bar %s" % self.place.name
26
@python_2_unicode_compatible
27
class Whiz(models.Model):
28
name = models.CharField(max_length=50)
31
return "Whiz %s" % self.name
33
@python_2_unicode_compatible
34
class Child(models.Model):
35
parent = models.OneToOneField('Base')
36
name = models.CharField(max_length=50)
39
return "Child %s" % self.name
41
@python_2_unicode_compatible
42
class Base(models.Model):
43
name = models.CharField(max_length=50)
46
return "Base %s" % self.name
48
@python_2_unicode_compatible
49
class Article(models.Model):
50
name = models.CharField(max_length=50)
51
text = models.TextField()
52
submitted_from = models.IPAddressField(blank=True, null=True)
55
return "Article %s" % self.name