On Saturday 16 December 2006 12:07, Rob Slotboom wrote:
> Hi Dirk,
> I think it's the other way around, try this
>
>
> class Content(models.Model):
>      title = models.CharField('Title', maxlength=255, core=True)
>      body  = models.TextField('Body text')
>
>     class Admin:
>       fields = (
>          (None, {'fields': ('title','body',)}),
>       )
>       list_display = ('title')
>       list_filter = ['title']   ## optional
>       search_fields = ['title']   ## optional
>       date_hierarchy = 'title'   ## optional
>       pass
>
> class Project(models.Model):
>     content  = models.OneToOneField(Content,
> edit_inline=models.TABULAR,  num_in_admin=1, core=True,
> related_name='project_content')
>     subtitle = models.CharField('Subtitle', maxlength=255, core=True)
>    def __str__(self):
>       return self.Subtitle

Hello Rob,

sorry for the delay. Yes that works, but as soon as i add another class - say 
News - which also has a OneToOneField(Content), the Content admin interface 
shows Project AND News inline. That's certainly not what i want.

I'd like to be able to edit Project and News separately with Content inline 
instead. Do you know what i mean?

# ---------------------------------------------------------------------
class Content(models.Model):
    title = models.CharField(maxlength=255, core=True)
    body  = models.TextField()
    
    def __str__(self):
        return self.title
          
    class Admin:
        pass

class Project(models.Model):
    subtitle = models.CharField(maxlength=255, null=True, blank=True)    
    content  = models.OneToOneField(Content, unique=True,               
               edit_inline=models.TABULAR, num_in_admin=1, core=True,           
     
               related_name='project_content')
    
    def __str__(self):
        return "%s - %s" % (self.content.title, self.subtitle)

class News(models.Model):
    date = models.DateTimeField(default=datetime.now())
    content = models.OneToOneField(Content, unique=True,
              edit_inline=models.TABULAR, num_in_admin=1, core=True,
              related_name='news_content')    
    
    def __str__(self):
        return "%s - %s" % (self.content.title, self.date)
# ---------------------------------------------------------------------

Thanks,
Dirk

-- 
Dirk Eschler <mailto:[EMAIL PROTECTED]>
http://www.krusader.org

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to