Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.conf import settings
- from django.db import models
- from django.utils.translation import ugettext as _
- # Move timestampable to a separate behaviors.py file
- class Timestampable(models.Model):
- """Abstract base class that provides auto-updating created and modified timestamps"""
- created = models.DateTimeField(_('Created'), auto_now_add=True, db_index=True, help_text=_('Created timestamp'))
- modified = models.DateTimeField(_('Modified'), auto_now=True, db_index=True, help_text=_('Last modified timestamp'))
- class Meta:
- abstract = True
- class Category(Timestampable, models.Model):
- """Comment about the purpose of this model"""
- name = models.CharField(_('Name'), max_length=25, db_index=True, help_text=_('The name of the category'))
- submit_date = models.DateTimeField(_('Submitted'), editable=False, help_text=_('When the category was submitted'))
- edit_date = models.DateTimeField(_('Editted'), editable=True, help_text=_('The last time the category was editted'))
- submit_user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
- edit_user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
- # Custom manager: https://docs.djangoproject.com/en/1.10/topics/db/managers/#from-queryset
- # objects = managers.CategoryManager.from_queryset(querysets.CategoryQueryset)()
- class Meta:
- verbose_name = _('Category')
- verbose_name_plural = _('Categories')
- def __str__(self):
- return self.name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement