display my images available in one class using another class in webpage

22 views
Skip to first unread message

aditya gupta

unread,
Jul 21, 2018, 6:35:32 AM7/21/18
to django...@googlegroups.com
 my Code :


class Gallery(models.Model):
    GameName=models.CharField(max_length=40)
    D_text=models.CharField(max_length=50)
    Gime=models.ImageField(upload_to='media/',null=True,blank=True)
    
class Assassin(models.Model):
    Gimage=models.ImageField(upload_to='media/assassin',null=True,blank=True)
    imagegallery=models.ForeignKey('Gallery',on_delete='CASCADE')
  
( In localhost Admin
 imagegallery = Gallery Object 1 )

class Batman(models.Model):
    Gimage=models.ImageField(upload_to='media/batman',null=True,blank=True)
    imagegallery=models.ForeignKey('Gallery',on_delete='CASCADE')   


( In localhost Admin
 imagegallery = Gallery Object 2 )


 How can I link my class "Assassin"  to class "Gallery" object 1 and class "Batman" to class "Gallery" object 2, so that when I call object 1 of Gallery in my Html file the images of Assassin class can also be shown. 

aditya gupta

unread,
Jul 22, 2018, 9:33:46 PM7/22/18
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages