from django db import models from django contrib sites models import S

 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
from django.db import models
from django.contrib.sites.models import Site
import mptt
# Create your models here.
class TypeofthePage(models.Model):
type_name = models.CharField(max_length=30)
template_name = models.FileField(upload_to = "pages_templates")
def __unicode__(self):
return self.type_name
class Admin:
pass
class SomePage(models.Model):
page_name = models.CharField(max_length=30)
page_site = models.ForeignKey(Site)
page_type = models.ForeignKey(TypeofthePage)
parent = models.ForeignKey('self',related_name='childs', blank=True, null=True)
page_first_menu = models.BooleanField()
page_second_menu = models.BooleanField()
page_third_menu = models.BooleanField()
def __unicode__(self):
return self.page_name
class Admin:
pass
class Meta:
unique_together = ("page_name", "page_site", "parent")
mptt.register(SomePage, order_insertion_by='page_name')