Jet fork des offiziellen jet-admin projekts. Geupdated für Django4.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

36 lignes
883B

  1. from django.db import models
  2. try:
  3. from django.utils.encoding import python_2_unicode_compatible
  4. except ImportError:
  5. from six import python_2_unicode_compatible
  6. @python_2_unicode_compatible
  7. class TestModel(models.Model):
  8. field1 = models.CharField(max_length=255)
  9. field2 = models.IntegerField()
  10. def __str__(self):
  11. return '%s%d' % (self.field1, self.field2)
  12. @python_2_unicode_compatible
  13. class RelatedToTestModel(models.Model):
  14. field = models.ForeignKey(TestModel, on_delete=models.CASCADE)
  15. def __str__(self):
  16. return self.field
  17. @python_2_unicode_compatible
  18. class SearchableTestModel(models.Model):
  19. field1 = models.CharField(max_length=255)
  20. field2 = models.IntegerField()
  21. def __str__(self):
  22. return '%s%d' % (self.field1, self.field2)
  23. @staticmethod
  24. def autocomplete_search_fields():
  25. return 'field1'