add parents as inline to contents
This commit is contained in:
parent
162af16b32
commit
8c2c532ce7
|
@ -6,6 +6,10 @@ from django.contrib import admin
|
|||
# Register your models here.
|
||||
from models import *
|
||||
|
||||
|
||||
class ContentParentsInline(admin.TabularInline):
|
||||
model = ContentContent
|
||||
fk_name = 'contentid1'
|
||||
'''
|
||||
class SubdomainInline(admin.StackedInline):
|
||||
model = Subdomain
|
||||
|
@ -22,6 +26,7 @@ class ContentAdmin(admin.ModelAdmin):
|
|||
list_display = ('__unicode__', 'datestart', 'type')
|
||||
list_filter = ['datestart', 'type']
|
||||
search_fields = ['title', 'body', 'header']
|
||||
inlines = [ContentParentsInline]
|
||||
|
||||
# inlines = [SubdomainInline, DomainAliasInline]
|
||||
# list_display = ('url', 'server', 'manage_nameserver', 'domain_registrar', 'email', 'is_active')
|
||||
|
|
|
@ -75,7 +75,7 @@ class Content(models.Model):
|
|||
view = models.ForeignKey("Views", null=True, blank=True, db_column="view")
|
||||
place = models.CharField(max_length=255, null=True, blank=True)
|
||||
parentid = models.ForeignKey("Content", null=True, db_column='parentID', blank=True, limit_choices_to={'type_id': 3}, related_name="please_run") # Field name made lowercase.
|
||||
content_related = models.ManyToManyField('Content', through='ContentContent', related_name= "run_run_run")
|
||||
parents = models.ManyToManyField('Content', through='ContentContent', related_name= "children")
|
||||
|
||||
def __unicode__(self):
|
||||
return self.title
|
||||
|
@ -87,8 +87,11 @@ class Content(models.Model):
|
|||
|
||||
|
||||
class ContentContent(models.Model):
|
||||
contentid1 = models.ForeignKey("content", db_column='contentID1', related_name="from_content") # Field name made lowercase.
|
||||
contentid2 = models.ForeignKey("content", db_column='contentID2', related_name="to_content") # Field name made lowercase.
|
||||
contentid1 = models.ForeignKey("content", db_column='contentID1', related_name="child") # Field name made lowercase.
|
||||
contentid2 = models.ForeignKey("content", db_column='contentID2', related_name="parent") # Field name made lowercase.
|
||||
|
||||
def __unicode__(self):
|
||||
return "%s is child of %s" % (self.contentid1.title, self.contentid2.title,)
|
||||
|
||||
class Meta:
|
||||
managed = False
|
||||
|
|
Loading…
Reference in New Issue
Block a user