<s> import datetime <EOL> from django . db import models <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> @ python_2_unicode_compatible <EOL> class Country ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:50> ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Person ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT> ) <EOL> person_country_id = models . IntegerField ( ) <EOL> person_country = models . ForeignObject ( <EOL> Country , <EOL> from_fields = [ '<STR_LIT>' ] , <EOL> to_fields = [ '<STR_LIT:id>' ] , <EOL> on_delete = models . CASCADE , <EOL> ) <EOL> friends = models . ManyToManyField ( '<STR_LIT>' , through = '<STR_LIT>' , symmetrical = False ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Group ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT> ) <EOL> group_country = models . ForeignKey ( Country , models . CASCADE ) <EOL> members = models . ManyToManyField ( Person , related_name = '<STR_LIT>' , through = '<STR_LIT>' ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT:name>' , ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> @ python_2_unicode_compatible <EOL> class Membership ( models . Model ) : <EOL> membership_country = models . ForeignKey ( Country , models . CASCADE ) <EOL> date_joined = models . DateTimeField ( default = datetime . datetime . now ) <EOL> invite_reason = models . CharField ( max_length = <NUM_LIT:64> , null = True ) <EOL> person_id = models . IntegerField ( ) <EOL> group_id = models . IntegerField ( blank = True , null = True ) <EOL> person = models . ForeignObject ( <EOL> Person , <EOL> from_fields = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> to_fields = [ '<STR_LIT:id>' , '<STR_LIT>' ] , <EOL> on_delete = models . CASCADE , <EOL> ) <EOL> group = models . ForeignObject ( <EOL> Group , <EOL> from_fields = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> to_fields = [ '<STR_LIT:id>' , '<STR_LIT>' ] , <EOL> on_delete = models . CASCADE , <EOL> ) <EOL> class Meta : <EOL> ordering = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __str__ ( self ) : <EOL> group_name = self . group . name if self . group_id else '<STR_LIT>' <EOL> return "<STR_LIT>" % ( self . person . name , group_name ) <EOL> class Friendship ( models . Model ) : <EOL> from_friend_country = models . ForeignKey ( Country , models . CASCADE , related_name = "<STR_LIT>" ) <EOL> from_friend_id = models . IntegerField ( ) <EOL> to_friend_country_id = models . IntegerField ( ) <EOL> to_friend_id = models . IntegerField ( ) <EOL> from_friend = models . ForeignObject ( <EOL> Person , <EOL> on_delete = models . CASCADE , <EOL> from_fields = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> to_fields = [ '<STR_LIT>' , '<STR_LIT:id>' ] , <EOL> related_name = '<STR_LIT>' ) <EOL> to_friend_country = models . ForeignObject ( <EOL> Country , <EOL> from_fields = [ '<STR_LIT>' ] , <EOL> to_fields = [ '<STR_LIT:id>' ] , <EOL> related_name = '<STR_LIT>' , <EOL> on_delete = models . CASCADE , <EOL> ) <EOL> to_friend = models . ForeignObject ( <EOL> Person , <EOL> from_fields = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> to_fields = [ '<STR_LIT>' , '<STR_LIT:id>' ] , <EOL> related_name = '<STR_LIT>' , <EOL> on_delete = models . CASCADE , <EOL> ) </s>
