-
Notifications
You must be signed in to change notification settings - Fork 96
/
models.py
39 lines (27 loc) · 983 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from __future__ import unicode_literals
from django.db import models
from django.db.models import ForeignKey, CASCADE
from nested_admin.tests.compat import python_2_unicode_compatible
@python_2_unicode_compatible
class Parent(models.Model):
name = models.CharField(max_length=128)
def __str__(self):
return self.name
@python_2_unicode_compatible
class Child(models.Model):
name = models.CharField(max_length=128)
parent = ForeignKey(Parent, on_delete=CASCADE, related_name='children')
position = models.PositiveIntegerField()
class Meta:
ordering = ['position']
def __str__(self):
return self.name
@python_2_unicode_compatible
class GrandChild(models.Model):
name = models.CharField(max_length=128)
parent = ForeignKey(Child, on_delete=CASCADE, related_name='children')
position = models.PositiveIntegerField()
class Meta:
ordering = ['position']
def __str__(self):
return self.name