How to get previously uploaded Images in Django

19 views
Skip to first unread message

Ahmed Khairy

unread,
May 3, 2020, 1:10:51 PM5/3/20
to Django users

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

Nomeh Uchenna Gabriel

unread,
May 4, 2020, 5:02:32 AM5/4/20
to Django users
You should read about customising the admin here: https://docs.djangoproject.com/en/3.0/intro/tutorial07/

... but I suggest that you build your own website control panel which will control your website with API's

Reply all
Reply to author
Forward
0 new messages