mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
36 lines
937 B
Python
36 lines
937 B
Python
from django.db import models
|
|
|
|
from model_utils.models import InheritanceCastModel, TimeStampedModel
|
|
from model_utils.managers import QueryManager
|
|
from model_utils.fields import SplitField
|
|
|
|
|
|
class InheritParent(InheritanceCastModel):
|
|
pass
|
|
|
|
class InheritChild(InheritParent):
|
|
pass
|
|
|
|
class TimeStamp(TimeStampedModel):
|
|
pass
|
|
|
|
class Post(models.Model):
|
|
published = models.BooleanField()
|
|
confirmed = models.BooleanField()
|
|
order = models.IntegerField()
|
|
|
|
objects = models.Manager()
|
|
public = QueryManager(published=True)
|
|
public_confirmed = QueryManager(models.Q(published=True) &
|
|
models.Q(confirmed=True))
|
|
public_reversed = QueryManager(published=True).order_by('-order')
|
|
|
|
class Meta:
|
|
ordering = ('order',)
|
|
|
|
class Article(models.Model):
|
|
title = models.CharField(max_length=50)
|
|
body = SplitField()
|
|
|
|
def __unicode__(self):
|
|
return self.title
|