Hello, I am converting from PHP to Django. In my Postgres database I have three tables:
models.py code: class Publication(models.Model): pubtitle = models.TextField() def __unicode__(self): return self.pubtitle class Pathology(models.Model): pathology = models.CharField(max_length=100) def __unicode__(self): return self.pathology class Pathpubcombo(models.Model): pathology = models.ForeignKey(Pathology) publication = models.ForeignKey(Publication) One publication can have many instances of pathology (one to many). The pathology list is used by another table (researchpub), as well. admin.py code: from mysite.fsafety.models import Pathology admin.site.register(Pathology) from mysite.fsafety.models import Pathpubcombo admin.site.register(Pathpubcombo) class PathpubInline(admin.TabularInline): model = Pathpubcombo fk_name = "publication" from mysite.fsafety.models import Publication class PublicationAdmin(admin.ModelAdmin): # ... list_display = ('pubtitle', 'year') search_fields = ['pubtitle', 'pubauthors'] fieldsets = [ (None, {'fields': ['active', 'pubtitle', 'pubauthors', 'pubcitationnum', 'pubwebaddress', 'month', 'year']}), ('Abstract', {'fields': ['pubabstract'], 'classes': ['collapse']}), ] inlines = [PathpubInline] admin.site.register(Publication,PublicationAdmin) My admin form - publication shows more than one pathology on the edit page, which means the above code works up to this point. It also gives me 3 empty fields that allows me to continue to add pathologies to the publication. When I add a new pathology and then save I receive the following error: duplicate key value violates unique constraint "fsafety_pathpubcombo_pkey" Can anyone please help? This is the first python code I've written. Thanks, Anna --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---