Viewing File: /opt/alt/python35/lib64/python3.5/site-packages/playhouse/__pycache__/gfk.cpython-35.opt-1.pyc
R6W @ s d Z d d l Td d l m Z d d l m Z d d l m Z d d l m Z d d l m Z e Z
i Z Gd d d e Z Gd
d d e e e Z d d
Z Gd d d e
Z Gd d d e
Z Gd d d e
Z d S)a
Provide a "Generic ForeignKey", similar to Django. A "GFK" is composed of two
columns: an object ID and an object type identifier. The object types are
collected in a global registry (all_models), so all you need to do is subclass
``gfk.Model`` and your model will be added to the registry.
Example:
class Tag(Model):
tag = CharField()
object_type = CharField(null=True)
object_id = IntegerField(null=True)
object = GFKField('object_type', 'object_id')
class Blog(Model):
tags = ReverseGFK(Tag, 'object_type', 'object_id')
class Photo(Model):
tags = ReverseGFK(Tag, 'object_type', 'object_id')
tag.object -> a blog or photo
blog.tags -> select query of tags for ``blog`` instance
Blog.tags -> select query of all tags for Blog instances
)*) BaseModel)Model)SelectQuery)UpdateQuery)with_metaclassc s"