models.py 618 B

123456789101112131415161718192021222324
  1. from django.db import models
  2. from django.utils.encoding import python_2_unicode_compatible
  3. @python_2_unicode_compatible
  4. class TestModel(models.Model):
  5. field1 = models.CharField(max_length=255)
  6. field2 = models.IntegerField()
  7. def __str__(self):
  8. return '%s%d' % (self.field1, self.field2)
  9. @python_2_unicode_compatible
  10. class SearchableTestModel(models.Model):
  11. field1 = models.CharField(max_length=255)
  12. field2 = models.IntegerField()
  13. def __str__(self):
  14. return '%s%d' % (self.field1, self.field2)
  15. @staticmethod
  16. def autocomplete_search_fields():
  17. return 'field1'