1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00
django/tests/extra_regress/models.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
Python
Raw Normal View History

import copy
import datetime
from django.contrib.auth.models import User
from django.db import models
class RevisionableModel(models.Model):
base = models.ForeignKey("self", models.SET_NULL, null=True)
title = models.CharField(blank=True, max_length=255)
when = models.DateTimeField(default=datetime.datetime.now)
def save(self, *args, force_insert=False, force_update=False, **kwargs):
super().save(
*args, force_insert=force_insert, force_update=force_update, **kwargs
)
if not self.base:
self.base = self
super().save(*args, **kwargs)
def new_revision(self):
new_revision = copy.copy(self)
new_revision.pk = None
return new_revision
class Order(models.Model):
created_by = models.ForeignKey(User, models.CASCADE)
text = models.TextField()
class TestObject(models.Model):
first = models.CharField(max_length=20)
second = models.CharField(max_length=20)
third = models.CharField(max_length=20)
def __str__(self):
2013-10-26 19:15:03 +00:00
return "TestObject: %s,%s,%s" % (self.first, self.second, self.third)