I am using Django 2.2 to make a project where designers upload designs and when I want to post them from admin, I want to choose their names and after I choose their names only their designs appear in the drop down list. So far I have reach the reach the designer name in a drop down list but I don't know how to link only their designs in the designs drop list.
I am using 2 different apps: 1."Score" where designers can upload their designs
2."Core" where I can list the items
First in the Score .model where designers upload the designs
class Post(models.Model):
designer_name = models.ForeignKey(User, on_delete=models.CASCADE)
design = models.ImageField(
blank=False, null=True, upload_to='new designs')
title = models.CharField(max_length=100)
def __str__(self):
return self.title
def get_absolute_url(self):
return reverse("score:post-detail", kwargs={"pk": self.pk})
Second in the Core App Model:
class Item(models.Model):
title = models.CharField(max_length=100)
description = models.TextField()
price = models.FloatField()
designer_name = models.ForeignKey(User, on_delete=models.CASCADE)
image = models.ImageField(blank=False, upload_to='imgs') **How can I make this a drop down list with the selected user's (designer's) all previously uploaded images to choose from instead of uploading new images**
def __str__(self):
return self.title
... but I suggest that you build your own website control panel which will control your website with API's