<s> from __future__ import unicode_literals <EOL> from datetime import datetime <EOL> from django . core . exceptions import ValidationError <EOL> from django . db import models <EOL> from django . utils . encoding import python_2_unicode_compatible <EOL> def validate_answer_to_universe ( value ) : <EOL> if value != <NUM_LIT> : <EOL> raise ValidationError ( '<STR_LIT>' , code = '<STR_LIT>' ) <EOL> class ModelToValidate ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> created = models . DateTimeField ( default = datetime . now ) <EOL> number = models . IntegerField ( db_column = '<STR_LIT>' ) <EOL> parent = models . ForeignKey ( '<STR_LIT>' , blank = True , null = True , limit_choices_to = { '<STR_LIT>' : <NUM_LIT:10> } ) <EOL> email = models . EmailField ( blank = True ) <EOL> url = models . URLField ( blank = True ) <EOL> f_with_custom_validator = models . IntegerField ( blank = True , null = True , validators = [ validate_answer_to_universe ] ) <EOL> slug = models . SlugField ( blank = True ) <EOL> def clean ( self ) : <EOL> super ( ModelToValidate , self ) . clean ( ) <EOL> if self . number == <NUM_LIT:11> : <EOL> raise ValidationError ( '<STR_LIT>' ) <EOL> class UniqueFieldsModel ( models . Model ) : <EOL> unique_charfield = models . CharField ( max_length = <NUM_LIT:100> , unique = True ) <EOL> unique_integerfield = models . IntegerField ( unique = True ) <EOL> non_unique_field = models . IntegerField ( ) <EOL> class CustomPKModel ( models . Model ) : <EOL> my_pk_field = models . CharField ( max_length = <NUM_LIT:100> , primary_key = True ) <EOL> class UniqueTogetherModel ( models . Model ) : <EOL> cfield = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> ifield = models . IntegerField ( ) <EOL> efield = models . EmailField ( ) <EOL> class Meta : <EOL> unique_together = ( ( '<STR_LIT>' , '<STR_LIT>' , ) , [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class UniqueForDateModel ( models . Model ) : <EOL> start_date = models . DateField ( ) <EOL> end_date = models . DateTimeField ( ) <EOL> count = models . IntegerField ( unique_for_date = "<STR_LIT>" , unique_for_year = "<STR_LIT>" ) <EOL> order = models . IntegerField ( unique_for_month = "<STR_LIT>" ) <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> class CustomMessagesModel ( models . Model ) : <EOL> other = models . IntegerField ( blank = True , null = True ) <EOL> number = models . IntegerField ( db_column = '<STR_LIT>' , <EOL> error_messages = { '<STR_LIT:null>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> validators = [ validate_answer_to_universe ] <EOL> ) <EOL> class Author ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> class Article ( models . Model ) : <EOL> title = models . CharField ( max_length = <NUM_LIT:100> ) <EOL> author = models . ForeignKey ( Author ) <EOL> pub_date = models . DateTimeField ( blank = True ) <EOL> def clean ( self ) : <EOL> if self . pub_date is None : <EOL> self . pub_date = datetime . now ( ) <EOL> @ python_2_unicode_compatible <EOL> class Post ( models . Model ) : <EOL> title = models . CharField ( max_length = <NUM_LIT:50> , unique_for_date = '<STR_LIT>' , blank = True ) <EOL> slug = models . CharField ( max_length = <NUM_LIT:50> , unique_for_year = '<STR_LIT>' , blank = True ) <EOL> subtitle = models . CharField ( max_length = <NUM_LIT:50> , unique_for_month = '<STR_LIT>' , blank = True ) <EOL> posted = models . DateField ( ) <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class FlexibleDatePost ( models . Model ) : <EOL> title = models . CharField ( max_length = <NUM_LIT:50> , unique_for_date = '<STR_LIT>' , blank = True ) <EOL> slug = models . CharField ( max_length = <NUM_LIT:50> , unique_for_year = '<STR_LIT>' , blank = True ) <EOL> subtitle = models . CharField ( max_length = <NUM_LIT:50> , unique_for_month = '<STR_LIT>' , blank = True ) <EOL> posted = models . DateField ( blank = True , null = True ) <EOL> class UniqueErrorsModel ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT:100> , unique = True , error_messages = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> no = models . IntegerField ( unique = True , error_messages = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> class GenericIPAddressTestModel ( models . Model ) : <EOL> generic_ip = models . GenericIPAddressField ( blank = True , null = True , unique = True ) <EOL> v4_ip = models . GenericIPAddressField ( blank = True , null = True , protocol = "<STR_LIT>" ) <EOL> v6_ip = models . GenericIPAddressField ( blank = True , null = True , protocol = "<STR_LIT>" ) <EOL> ip_verbose_name = models . GenericIPAddressField ( "<STR_LIT>" , <EOL> blank = True , null = True ) <EOL> class GenericIPAddrUnpackUniqueTest ( models . Model ) : <EOL> generic_v4unpack_ip = models . GenericIPAddressField ( null = True , blank = True , unique = True , unpack_ipv4 = True ) <EOL> assertion_error = None <EOL> try : <EOL> class MultipleAutoFields ( models . Model ) : <EOL> auto1 = models . AutoField ( primary_key = True ) <EOL> auto2 = models . AutoField ( primary_key = True ) <EOL> except AssertionError as exc : <EOL> assertion_error = exc <EOL> assert str ( assertion_error ) == "<STR_LIT>" </s>
