mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
6b5a240d50
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13895 bcc190cf-cafb-0310-a4f2-bffc1f526a37
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from django.db import models
|
|
|
|
class Foo(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
friend = models.CharField(max_length=50, blank=True)
|
|
|
|
def __unicode__(self):
|
|
return "Foo %s" % self.name
|
|
|
|
class Bar(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
normal = models.ForeignKey(Foo, related_name='normal_foo')
|
|
fwd = models.ForeignKey("Whiz")
|
|
back = models.ForeignKey("Foo")
|
|
|
|
def __unicode__(self):
|
|
return "Bar %s" % self.place.name
|
|
|
|
class Whiz(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
|
|
def __unicode__(self):
|
|
return "Whiz %s" % self.name
|
|
|
|
class Child(models.Model):
|
|
parent = models.OneToOneField('Base')
|
|
name = models.CharField(max_length=50)
|
|
|
|
def __unicode__(self):
|
|
return "Child %s" % self.name
|
|
|
|
class Base(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
|
|
def __unicode__(self):
|
|
return "Base %s" % self.name
|
|
|
|
class Article(models.Model):
|
|
name = models.CharField(max_length=50)
|
|
text = models.TextField()
|
|
submitted_from = models.IPAddressField(blank=True, null=True)
|
|
|
|
def __str__(self):
|
|
return "Article %s" % self.name
|