python - Related to django admin customization -


in django let have 3 models

class publisher(models.model):     name = models.charfield(max_length=255)   class author(models.model):     name = models.charfield(max_length=255)     publisher = models.foreignkey(publisher)   class book(models.model):     name = models.charfield(max_length=255)     publisher = models.foreignkey(author) 

in django admin adding new book if want have publisher field in form also.how can it? appreciate help.

if want show publisher along author (not choose or create new publisher) then, can modify author model display both author name , publisher name in select field author.

class author(models.model):     name = models.charfield(max_length=255)     publisher = models.foreignkey(publisher)      def __repr__(self):         return self.name + ' - ' + self.publisher.name 

Comments

Popular posts from this blog

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -