PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/django/branches/attic/magic-removal/tests/modeltests/invalid_models/models.py

https://bitbucket.org/mirror/django/
Python | 117 lines | 94 code | 20 blank | 3 comment | 0 complexity | 5de1708fea708f4fc9388f0f01df539e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. """
  2. 26. A test to check that the model validator works can correctly identify errors in a model.
  3. """
  4. from django.db import models
  5. class FieldErrors(models.Model):
  6. charfield = models.CharField()
  7. floatfield = models.FloatField()
  8. filefield = models.FileField()
  9. prepopulate = models.CharField(maxlength=10, prepopulate_from='bad')
  10. choices = models.CharField(maxlength=10, choices='bad')
  11. choices2 = models.CharField(maxlength=10, choices=[(1,2,3),(1,2,3)])
  12. index = models.CharField(maxlength=10, db_index='bad')
  13. class Target(models.Model):
  14. tgt_safe = models.CharField(maxlength=10)
  15. clash1_set = models.CharField(maxlength=10)
  16. class Clash1(models.Model):
  17. src_safe = models.CharField(maxlength=10)
  18. foreign = models.ForeignKey(Target)
  19. m2m = models.ManyToManyField(Target)
  20. class Clash2(models.Model):
  21. src_safe = models.CharField(maxlength=10)
  22. foreign_1 = models.ForeignKey(Target, related_name='id')
  23. foreign_2 = models.ForeignKey(Target, related_name='src_safe')
  24. m2m_1 = models.ManyToManyField(Target, related_name='id')
  25. m2m_2 = models.ManyToManyField(Target, related_name='src_safe')
  26. class Target2(models.Model):
  27. foreign_tgt = models.ForeignKey(Target)
  28. clashforeign_set = models.ForeignKey(Target)
  29. m2m_tgt = models.ManyToManyField(Target)
  30. clashm2m_set = models.ManyToManyField(Target)
  31. class Clash3(models.Model):
  32. foreign_1 = models.ForeignKey(Target2, related_name='foreign_tgt')
  33. foreign_2 = models.ForeignKey(Target2, related_name='m2m_tgt')
  34. m2m_1 = models.ManyToManyField(Target2, related_name='foreign_tgt')
  35. m2m_2 = models.ManyToManyField(Target2, related_name='m2m_tgt')
  36. class ClashForeign(models.Model):
  37. foreign = models.ForeignKey(Target2)
  38. class ClashM2M(models.Model):
  39. m2m = models.ManyToManyField(Target2)
  40. class SelfClashForeign(models.Model):
  41. src_safe = models.CharField(maxlength=10)
  42. selfclashforeign_set = models.ForeignKey("SelfClashForeign")
  43. foreign_1 = models.ForeignKey("SelfClashForeign", related_name='id')
  44. foreign_2 = models.ForeignKey("SelfClashForeign", related_name='src_safe')
  45. class SelfClashM2M(models.Model):
  46. src_safe = models.CharField(maxlength=10)
  47. selfclashm2m_set = models.ManyToManyField("SelfClashM2M")
  48. m2m_1 = models.ManyToManyField("SelfClashM2M", related_name='id')
  49. m2m_2 = models.ManyToManyField("SelfClashM2M", related_name='src_safe')
  50. error_log = """invalid_models.fielderrors: "charfield": CharFields require a "maxlength" attribute.
  51. invalid_models.fielderrors: "floatfield": FloatFields require a "decimal_places" attribute.
  52. invalid_models.fielderrors: "floatfield": FloatFields require a "max_digits" attribute.
  53. invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute.
  54. invalid_models.fielderrors: "prepopulate": prepopulate_from should be a list or tuple.
  55. invalid_models.fielderrors: "choices": "choices" should be either a tuple or list.
  56. invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples.
  57. invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples.
  58. invalid_models.fielderrors: "index": "db_index" should be either None, True or False.
  59. invalid_models.clash1: 'foreign' accessor name 'Target.clash1_set' clashes with another field. Add a related_name argument to the definition for 'foreign'.
  60. invalid_models.clash1: 'foreign' accessor name 'Target.clash1_set' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign'.
  61. invalid_models.clash1: 'm2m' m2m accessor name 'Target.clash1_set' clashes with another field. Add a related_name argument to the definition for 'm2m'.
  62. invalid_models.clash1: 'm2m' m2m accessor name 'Target.clash1_set' clashes with another related field. Add a related_name argument to the definition for 'm2m'.
  63. invalid_models.clash2: 'foreign_1' accessor name 'Target.id' clashes with another field. Add a related_name argument to the definition for 'foreign_1'.
  64. invalid_models.clash2: 'foreign_1' accessor name 'Target.id' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign_1'.
  65. invalid_models.clash2: 'foreign_2' accessor name 'Target.src_safe' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign_2'.
  66. invalid_models.clash2: 'm2m_1' m2m accessor name 'Target.id' clashes with another field. Add a related_name argument to the definition for 'm2m_1'.
  67. invalid_models.clash2: 'm2m_1' m2m accessor name 'Target.id' clashes with another related field. Add a related_name argument to the definition for 'm2m_1'.
  68. invalid_models.clash2: 'm2m_2' m2m accessor name 'Target.src_safe' clashes with another related field. Add a related_name argument to the definition for 'm2m_2'.
  69. invalid_models.clash3: 'foreign_1' accessor name 'Target2.foreign_tgt' clashes with another field. Add a related_name argument to the definition for 'foreign_1'.
  70. invalid_models.clash3: 'foreign_1' accessor name 'Target2.foreign_tgt' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign_1'.
  71. invalid_models.clash3: 'foreign_2' accessor name 'Target2.m2m_tgt' clashes with a m2m field. Add a related_name argument to the definition for 'foreign_2'.
  72. invalid_models.clash3: 'foreign_2' accessor name 'Target2.m2m_tgt' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign_2'.
  73. invalid_models.clash3: 'm2m_1' m2m accessor name 'Target2.foreign_tgt' clashes with another field. Add a related_name argument to the definition for 'm2m_1'.
  74. invalid_models.clash3: 'm2m_1' m2m accessor name 'Target2.foreign_tgt' clashes with another related field. Add a related_name argument to the definition for 'm2m_1'.
  75. invalid_models.clash3: 'm2m_2' m2m accessor name 'Target2.m2m_tgt' clashes with a m2m field. Add a related_name argument to the definition for 'm2m_2'.
  76. invalid_models.clash3: 'm2m_2' m2m accessor name 'Target2.m2m_tgt' clashes with another related field. Add a related_name argument to the definition for 'm2m_2'.
  77. invalid_models.clashforeign: 'foreign' accessor name 'Target2.clashforeign_set' clashes with another field. Add a related_name argument to the definition for 'foreign'.
  78. invalid_models.clashm2m: 'm2m' m2m accessor name 'Target2.clashm2m_set' clashes with a m2m field. Add a related_name argument to the definition for 'm2m'.
  79. invalid_models.target2: 'foreign_tgt' accessor name 'Target.target2_set' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign_tgt'.
  80. invalid_models.target2: 'foreign_tgt' accessor name 'Target.target2_set' clashes with a related m2m field. Add a related_name argument to the definition for 'foreign_tgt'.
  81. invalid_models.target2: 'foreign_tgt' accessor name 'Target.target2_set' clashes with another related field. Add a related_name argument to the definition for 'foreign_tgt'.
  82. invalid_models.target2: 'clashforeign_set' accessor name 'Target.target2_set' clashes with a related m2m field. Add a related_name argument to the definition for 'clashforeign_set'.
  83. invalid_models.target2: 'clashforeign_set' accessor name 'Target.target2_set' clashes with a related m2m field. Add a related_name argument to the definition for 'clashforeign_set'.
  84. invalid_models.target2: 'clashforeign_set' accessor name 'Target.target2_set' clashes with another related field. Add a related_name argument to the definition for 'clashforeign_set'.
  85. invalid_models.target2: 'm2m_tgt' m2m accessor name 'Target.target2_set' clashes with a related m2m field. Add a related_name argument to the definition for 'm2m_tgt'.
  86. invalid_models.target2: 'm2m_tgt' m2m accessor name 'Target.target2_set' clashes with another related field. Add a related_name argument to the definition for 'm2m_tgt'.
  87. invalid_models.target2: 'm2m_tgt' m2m accessor name 'Target.target2_set' clashes with another related field. Add a related_name argument to the definition for 'm2m_tgt'.
  88. invalid_models.target2: 'clashm2m_set' m2m accessor name 'Target.target2_set' clashes with a related m2m field. Add a related_name argument to the definition for 'clashm2m_set'.
  89. invalid_models.target2: 'clashm2m_set' m2m accessor name 'Target.target2_set' clashes with another related field. Add a related_name argument to the definition for 'clashm2m_set'.
  90. invalid_models.target2: 'clashm2m_set' m2m accessor name 'Target.target2_set' clashes with another related field. Add a related_name argument to the definition for 'clashm2m_set'.
  91. invalid_models.selfclashforeign: 'selfclashforeign_set' accessor name 'SelfClashForeign.selfclashforeign_set' clashes with another field. Add a related_name argument to the definition for 'selfclashforeign_set'.
  92. invalid_models.selfclashforeign: 'foreign_1' accessor name 'SelfClashForeign.id' clashes with another field. Add a related_name argument to the definition for 'foreign_1'.
  93. invalid_models.selfclashforeign: 'foreign_2' accessor name 'SelfClashForeign.src_safe' clashes with another field. Add a related_name argument to the definition for 'foreign_2'.
  94. invalid_models.selfclashm2m: 'selfclashm2m_set' m2m accessor name 'SelfClashM2M.selfclashm2m_set' clashes with a m2m field. Add a related_name argument to the definition for 'selfclashm2m_set'.
  95. invalid_models.selfclashm2m: 'm2m_1' m2m accessor name 'SelfClashM2M.id' clashes with another field. Add a related_name argument to the definition for 'm2m_1'.
  96. invalid_models.selfclashm2m: 'm2m_2' m2m accessor name 'SelfClashM2M.src_safe' clashes with another field. Add a related_name argument to the definition for 'm2m_2'.
  97. """