Changeset 3028
- Timestamp:
- 05/31/06 13:45:17 (2 years ago)
- Files:
-
- django/trunk/tests/modeltests/custom_managers/models.py (modified) (2 diffs)
- django/trunk/tests/modeltests/invalid_models/models.py (modified) (5 diffs)
- django/trunk/tests/modeltests/manipulators/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/model_inheritance/models.py (modified) (1 diff)
- django/trunk/tests/modeltests/properties/models.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/modeltests/custom_managers/models.py
r2809 r3028 1 1 """ 2 2 23. Giving models a custom manager 3 4 You can use a custom ``Manager`` in a particular model by extending the base 5 ``Manager`` class and instantiating your custom ``Manager`` in your model. 6 7 There are two reasons you might want to customize a ``Manager``: to add extra 8 ``Manager`` methods, and/or to modify the initial ``QuerySet`` the ``Manager`` 9 returns. 3 10 """ 4 11 … … 20 27 return "%s %s" % (self.first_name, self.last_name) 21 28 22 # An example of a custom manager that sets a core_filter on its lookups.29 # An example of a custom manager that sets get_query_set(). 23 30 24 31 class PublishedBookManager(models.Manager): django/trunk/tests/modeltests/invalid_models/models.py
r2809 r3028 1 1 """ 2 26. A test to check that the model validator works can correctly identify errors in a model. 2 26. Invalid models 3 4 This example exists purely to point out errors in models. 3 5 """ 4 6 … … 12 14 choices = models.CharField(maxlength=10, choices='bad') 13 15 choices2 = models.CharField(maxlength=10, choices=[(1,2,3),(1,2,3)]) 14 index = models.CharField(maxlength=10, db_index='bad') 16 index = models.CharField(maxlength=10, db_index='bad') 15 17 16 18 class Target(models.Model): 17 19 tgt_safe = models.CharField(maxlength=10) 18 20 19 21 clash1_set = models.CharField(maxlength=10) 20 22 21 23 class Clash1(models.Model): 22 24 src_safe = models.CharField(maxlength=10) 23 25 24 26 foreign = models.ForeignKey(Target) 25 27 m2m = models.ManyToManyField(Target) … … 37 39 foreign_tgt = models.ForeignKey(Target) 38 40 clashforeign_set = models.ForeignKey(Target) 39 41 40 42 m2m_tgt = models.ManyToManyField(Target) 41 43 clashm2m_set = models.ManyToManyField(Target) … … 44 46 foreign_1 = models.ForeignKey(Target2, related_name='foreign_tgt') 45 47 foreign_2 = models.ForeignKey(Target2, related_name='m2m_tgt') 46 48 47 49 m2m_1 = models.ManyToManyField(Target2, related_name='foreign_tgt') 48 50 m2m_2 = models.ManyToManyField(Target2, related_name='m2m_tgt') 49 51 50 52 class ClashForeign(models.Model): 51 53 foreign = models.ForeignKey(Target2) … … 53 55 class ClashM2M(models.Model): 54 56 m2m = models.ManyToManyField(Target2) 55 57 56 58 class SelfClashForeign(models.Model): 57 59 src_safe = models.CharField(maxlength=10) 58 59 selfclashforeign_set = models.ForeignKey("SelfClashForeign") 60 61 selfclashforeign_set = models.ForeignKey("SelfClashForeign") 60 62 foreign_1 = models.ForeignKey("SelfClashForeign", related_name='id') 61 63 foreign_2 = models.ForeignKey("SelfClashForeign", related_name='src_safe') django/trunk/tests/modeltests/manipulators/models.py
r2809 r3028 1 1 """ 2 2 25. Default manipulators 3 4 Each model gets an AddManipulator and ChangeManipulator by default. 3 5 """ 4 6 django/trunk/tests/modeltests/model_inheritance/models.py
r2809 r3028 2 2 XX. Model inheritance 3 3 4 Model inheritance isn't yet supported. 4 5 """ 5 6 django/trunk/tests/modeltests/properties/models.py
r2809 r3028 1 1 """ 2 2 22. Using properties on models 3 4 Use properties on models just like on any other Python object. 3 5 """ 4 6
