Tomek Wójcik
c75ea4ea9d
* `bthlabs-jsonrpc-aiohttp` v1.0.0 * `bthlabs-jsonrpc-core` v1.0.0 * `bthlabs-jsonrpc-django` v1.0.0
30 lines
879 B
Python
30 lines
879 B
Python
# -*- coding: utf-8 -*-
|
|
from django.db import models
|
|
|
|
|
|
class Thing(models.Model):
|
|
name = models.CharField(max_length=255)
|
|
content = models.TextField()
|
|
created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
|
|
modified_at = models.DateTimeField(auto_now=True, auto_now_add=False)
|
|
is_active = models.BooleanField(default=True, db_index=True)
|
|
|
|
owner = models.ForeignKey(
|
|
'auth.User', null=True, blank=True, on_delete=models.CASCADE,
|
|
)
|
|
|
|
class Meta:
|
|
verbose_name = 'thing'
|
|
verbose_name_plural = 'things'
|
|
|
|
def to_rpc(self):
|
|
return {
|
|
'id': self.pk,
|
|
'name': self.name,
|
|
'content': self.content,
|
|
'created_at': self.created_at,
|
|
'modified_at': self.modified_at,
|
|
'is_active': self.is_active,
|
|
'owner_id': self.owner_id,
|
|
}
|