Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tehfink/django-extensions
base: 5632a0022d
...
head fork: tehfink/django-extensions
compare: 6e8ed84a6f
  • 4 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 9 additions and 5 deletions.
  1. +9 −5 django_extensions/db/models.py
View
14 django_extensions/db/models.py
@@ -17,6 +17,8 @@ class TimeStampedModel(models.Model):
modified = ModificationDateTimeField(_('modified'))
class Meta:
+ get_latest_by = 'modified'
+ ordering = ('-modified', '-created',)
abstract = True
@@ -39,23 +41,24 @@ class ActivatorModelManager(models.Manager):
"""
def active(self):
""" Returns active instances of ActivatorModel: SomeModel.objects.active() """
- return super(ActivatorModelManager, self).get_query_set().filter(status=1)
+ return self.get_query_set().filter(status=ActivatorModel.ACTIVE_STATUS)
def inactive(self):
""" Returns inactive instances of ActivatorModel: SomeModel.objects.inactive() """
- return super(ActivatorModelManager, self).get_query_set().filter(status=0)
+ return self.get_query_set().filter(status=ActivatorModel.INACTIVE_STATUS)
class ActivatorModel(models.Model):
""" ActivatorModel
An abstract base class model that provides activate and deactivate fields.
"""
+ INACTIVE_STATUS, ACTIVE_STATUS = range(2)
STATUS_CHOICES = (
- (0, _('Inactive')),
- (1, _('Active')),
+ (INACTIVE_STATUS, _('Inactive')),
+ (ACTIVE_STATUS, _('Active')),
)
status = models.IntegerField(_('status'), choices=STATUS_CHOICES,
- default=1)
+ default=ACTIVE_STATUS)
activate_date = models.DateTimeField(blank=True, null=True,
help_text=_('keep empty for an immediate activation'))
deactivate_date = models.DateTimeField(blank=True, null=True,
@@ -63,6 +66,7 @@ class ActivatorModel(models.Model):
objects = ActivatorModelManager()
class Meta:
+ ordering = ('status', '-activate_date',)
abstract = True
def save(self, *args, **kwargs):

No commit comments for this range

Something went wrong with that request. Please try again.