I have a manytomany relationship between publication and pathology.
Each publication can have many pathologies. When a publication appears
in the admin template, I need to be able to see the many pathologies
associated with that publication. Here is the model statement:

class Pathology(models.Model):
    pathology = models.CharField(max_length=100)
    def __unicode__(self):
        return self.pathology
    class Meta:
        ordering = ["pathology"]

class Publication(models.Model):
    pubtitle = models.TextField()
    pathology = models.ManyToManyField(Pathology)
    def __unicode__(self):
        return self.pubtitle
    class Meta:
        ordering = ["pubtitle"]

Here is the admin.py. I have tried variations of the following,
but always get an error saying either publication or pathology doesn't
have a foreign key associated.
I've even tried removing the inlines=[PathologyInline].

from myprograms.cpssite.models import Pathology
class PathologyAdmin(admin.ModelAdmin):
    # ...
    list_display = ('pathology', 'id')

admin.site.register(Pathology, PathologyAdmin)

class PathologyInline(admin.TabularInline):
    #...
    model = Pathology
    extra = 3

class PublicationAdmin(admin.ModelAdmin):
    # ...
    ordering = ('pubtitle', 'year')
    inlines = [PathologyInline]
admin.site.register(Publication,PublicationAdmin)

Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to