<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> from decimal import Decimal <EOL> from django . db import models <EOL> from django . utils import six <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> @ python_2_unicode_compatible <EOL> class Category ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:20> ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Author ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:20> ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Article ( models . Model ) : <EOL> author = models . ForeignKey ( Author ) <EOL> headline = models . CharField ( max_length = <NUM_LIT:50> ) <EOL> pub_date = models . DateTimeField ( ) <EOL> categories = models . ManyToManyField ( Category ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , ) <EOL> def __str__ ( self ) : <EOL> return self . headline <EOL> @ python_2_unicode_compatible <EOL> class AuthorProfile ( models . Model ) : <EOL> author = models . OneToOneField ( Author , primary_key = True ) <EOL> date_of_birth = models . DateField ( ) <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % self . author <EOL> @ python_2_unicode_compatible <EOL> class Actor ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:20> , primary_key = True ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Movie ( models . Model ) : <EOL> actor = models . ForeignKey ( Actor ) <EOL> title = models . CharField ( max_length = <NUM_LIT:50> ) <EOL> price = models . DecimalField ( max_digits = <NUM_LIT:6> , decimal_places = <NUM_LIT:2> , default = Decimal ( '<STR_LIT>' ) ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:title>' , ) <EOL> def __str__ ( self ) : <EOL> return self . title <EOL> class Score ( models . Model ) : <EOL> score = models . FloatField ( ) <EOL> @ python_2_unicode_compatible <EOL> class Team ( object ) : <EOL> def __init__ ( self , title ) : <EOL> self . title = title <EOL> def __str__ ( self ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> def to_string ( self ) : <EOL> return "<STR_LIT:%s>" % self . title <EOL> class TeamField ( six . with_metaclass ( models . SubfieldBase , models . CharField ) ) : <EOL> def __init__ ( self ) : <EOL> super ( TeamField , self ) . __init__ ( max_length = <NUM_LIT:100> ) <EOL> def get_db_prep_save ( self , value , connection ) : <EOL> return six . text_type ( value . title ) <EOL> def to_python ( self , value ) : <EOL> if isinstance ( value , Team ) : <EOL> return value <EOL> return Team ( value ) <EOL> def value_to_string ( self , obj ) : <EOL> return self . _get_val_from_obj ( obj ) . to_string ( ) <EOL> @ python_2_unicode_compatible <EOL> class Player ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:50> ) <EOL> rank = models . IntegerField ( ) <EOL> team = TeamField ( ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' % ( self . name , self . rank , self . team . to_string ( ) ) </s>
