models.py 676 B

1234567891011121314151617
  1. # textdocs/models.py
  2. from django.db import models
  3. from django.urls import reverse
  4. class Document(models.Model):
  5. """Represents a single document with its fixed sections."""
  6. title = models.CharField(max_length=255)
  7. introduction = models.TextField(help_text="The introductory section of the document.")
  8. main_body = models.TextField(help_text="The main content or analysis.")
  9. conclusion = models.TextField(help_text="The concluding remarks or summary.")
  10. created_at = models.DateTimeField(auto_now_add=True)
  11. def __str__(self):
  12. return self.title
  13. def get_absolute_url(self):
  14. return reverse('document_detail', kwargs={'pk': self.pk})