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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -