mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-03-16 22:20:24 +00:00
68 lines
1.8 KiB
Python
68 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import division, absolute_import, unicode_literals
|
|
|
|
from django.db import models
|
|
from django.utils import six
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class Post(models.Model):
|
|
title = models.CharField(max_length=255, verbose_name=_('title'))
|
|
body = models.TextField(verbose_name=_('body'))
|
|
published = models.BooleanField(default=False, verbose_name=_('published'))
|
|
published_date = models.DateField(blank=True, null=True)
|
|
|
|
def __str__(self):
|
|
return self.title
|
|
|
|
class Meta:
|
|
verbose_name = _('post')
|
|
verbose_name_plural = _('posts')
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class Comment(models.Model):
|
|
post = models.ForeignKey(
|
|
Post, verbose_name=_('post'), related_name="comments",
|
|
on_delete=models.CASCADE)
|
|
body = models.TextField(verbose_name=_('body'))
|
|
|
|
def __str__(self):
|
|
return self.body
|
|
|
|
class Meta:
|
|
verbose_name = _('comment')
|
|
verbose_name_plural = _('comments')
|
|
|
|
|
|
# Models needed for testing NestedObjects
|
|
|
|
@python_2_unicode_compatible
|
|
class Count(models.Model):
|
|
num = models.PositiveSmallIntegerField()
|
|
parent = models.ForeignKey('self', null=True, on_delete=models.CASCADE)
|
|
|
|
def __str__(self):
|
|
return six.text_type(self.num)
|
|
|
|
|
|
class Event(models.Model):
|
|
date = models.DateTimeField(auto_now_add=True)
|
|
|
|
|
|
class Location(models.Model):
|
|
event = models.OneToOneField(Event, verbose_name='awesome event')
|
|
|
|
|
|
class Guest(models.Model):
|
|
event = models.OneToOneField(Event)
|
|
name = models.CharField(max_length=255)
|
|
|
|
class Meta:
|
|
verbose_name = "awesome guest"
|
|
|
|
|
|
class EventGuide(models.Model):
|
|
event = models.ForeignKey(Event, on_delete=models.DO_NOTHING)
|