<s> """<STR_LIT>""" <EOL> from django . contrib . auth . models import Permission <EOL> from django . contrib . contenttypes import generic <EOL> from django . contrib . contenttypes . models import ContentType <EOL> from django . db import models <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> @ python_2_unicode_compatible <EOL> class Category ( models . Model ) : <EOL> title = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> description = models . TextField ( ) <EOL> def __str__ ( self ) : <EOL> return self . title <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:title>' , ) <EOL> @ python_2_unicode_compatible <EOL> class Article ( models . Model ) : <EOL> headline = models . CharField ( max_length = <NUM_LIT:100> , default = '<STR_LIT>' ) <EOL> pub_date = models . DateTimeField ( ) <EOL> def __str__ ( self ) : <EOL> return self . headline <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ python_2_unicode_compatible <EOL> class Blog ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> featured = models . ForeignKey ( Article , related_name = '<STR_LIT>' ) <EOL> articles = models . ManyToManyField ( Article , blank = True , <EOL> related_name = '<STR_LIT>' ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Tag ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> tagged_type = models . ForeignKey ( ContentType , related_name = "<STR_LIT>" ) <EOL> tagged_id = models . PositiveIntegerField ( default = <NUM_LIT:0> ) <EOL> tagged = generic . GenericForeignKey ( ct_field = '<STR_LIT>' , <EOL> fk_field = '<STR_LIT>' ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . tagged . __class__ . __name__ , <EOL> self . tagged , self . name ) <EOL> class PersonManager ( models . Manager ) : <EOL> def get_by_natural_key ( self , name ) : <EOL> return self . get ( name = name ) <EOL> @ python_2_unicode_compatible <EOL> class Person ( models . Model ) : <EOL> objects = PersonManager ( ) <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def natural_key ( self ) : <EOL> return ( self . name , ) <EOL> class SpyManager ( PersonManager ) : <EOL> def get_query_set ( self ) : <EOL> return super ( SpyManager , self ) . get_query_set ( ) . filter ( cover_blown = False ) <EOL> class Spy ( Person ) : <EOL> objects = SpyManager ( ) <EOL> cover_blown = models . BooleanField ( default = False ) <EOL> @ python_2_unicode_compatible <EOL> class Visa ( models . Model ) : <EOL> person = models . ForeignKey ( Person ) <EOL> permissions = models . ManyToManyField ( Permission , blank = True ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . person . name , <EOL> '<STR_LIT:U+002CU+0020>' . join ( p . name for p in self . permissions . all ( ) ) ) <EOL> @ python_2_unicode_compatible <EOL> class Book ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> authors = models . ManyToManyField ( Person ) <EOL> def __str__ ( self ) : <EOL> authors = '<STR_LIT>' . join ( a . name for a in self . authors . all ( ) ) <EOL> return '<STR_LIT>' % ( self . name , authors ) if authors else self . name <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) </s>
