mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
595c092a29
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10373 bcc190cf-cafb-0310-a4f2-bffc1f526a37
22 lines
694 B
Python
22 lines
694 B
Python
from django.db import models
|
|
from django.contrib.contenttypes import generic
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
class Link(models.Model):
|
|
content_type = models.ForeignKey(ContentType)
|
|
object_id = models.PositiveIntegerField()
|
|
content_object = generic.GenericForeignKey()
|
|
|
|
def __unicode__(self):
|
|
return "Link to %s id=%s" % (self.content_type, self.object_id)
|
|
|
|
class Place(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
links = generic.GenericRelation(Link)
|
|
|
|
def __unicode__(self):
|
|
return "Place: %s" % self.name
|
|
|
|
class Restaurant(Place):
|
|
def __unicode__(self):
|
|
return "Restaurant: %s" % self.name |