This is the old model.py that works well in that paragraphs and publications are part of the author model in admin
[code]
class Author(models.Model):
name = models.CharField(max_length=200, help_text="eg Sir John Smith KCMG")
picture = models.ImageField(upload_to='honorary_member_images', null=True, blank=True)
priority = models.IntegerField()
meta_title = models.CharField(max_length=100, null=True, blank=True)
meta_desc = models.CharField(max_length=250, null=True, blank=True)
meta_keywords = models.CharField(max_length=250, null=True, blank=True)
class Admin:
list_display = ('name', 'priority','masthead_strapline', 'masthead_colour',)
js = (
'../media-tiny_mce/tiny_mce.js',
'../media/js/pdf_editor.js',
)
def __unicode__( self ):
return
self.nameclass Paragraphs(models.Model):
author = models.ForeignKey(Author, edit_inline=True)
para_title = models.CharField(max_length=200, core=True)
para_text = models.TextField()
priority = models.IntegerField()
class Publications(models.Model):
author = models.ForeignKey(Author, edit_inline=True)
pub_title = models.CharField(max_length=200, core=True)
pub_precis = models.TextField(null=True, blank=True)
priority = models.IntegerField()
[/code]
So porting it would be....
[code]
class Author(models.Model):
name = models.CharField(max_length=200, help_text="eg Sir John Smith KCMG")
picture = models.ImageField(upload_to='honorary_member_images', null=True, blank=True)
priority = models.IntegerField()
meta_title = models.CharField(max_length=100, null=True, blank=True)
meta_desc = models.CharField(max_length=250, null=True, blank=True)
meta_keywords = models.CharField(max_length=250, null=True, blank=True)
def __unicode__( self ):
return
self.nameclass Paragraphs(models.Model):
author = models.ForeignKey(Author, related_name="paragraph_set")
para_title = models.CharField(max_length=200)
para_text = models.TextField()
priority = models.IntegerField()
class Publications(models.Model):
author = models.ForeignKey(Author, related_name="publication_set")
pub_title = models.CharField(max_length=200)
pub_precis = models.TextField(null=True, blank=True)
priority = models.IntegerField()
[/code]
but what about admin.py?
[code]
class Publications( admin.TabularInline ):
model = Publications
extra = 5
class Paragraphs( admin.TabularInline ):
model = Paragraphs
extra = 5
class AuthorAdmin( admin.ModelAdmin ):
inlines = [Publications] #?
inlines = [Paragraphs] #?
admin.site.register(Author, AuthorAdmin)
[/code]
I cant seem to find anything in the docs that addresses this, there is something very similar that would turn it upside down in that for
each publication and paragraph the author would be selected but what is needed is multiple unique paragraphs, multiple unique publications to be editable under the Author
Any ideas on how to represent that in admin.py please?