Hi All,

I am using Django2.0.6, Python3.6 and MySql.
I have a table Brand in db which have fields- id, name, description, 
image_url.
>From django admin I am uploading an image to s3 bucket.

For this I have created a class Brand in models.py as below-

class Brand(models.Model):
    name = models.CharField(max_length=60)
    description = models.TextField(blank=True, null=True)

    @property
    def logo(self):
        return get_logo(self.name, 'brand')

    class Meta:
        managed = False
        db_table = 'brand'

    def __str__(self):
        return self.name


def get_logo(logo_name, folder):
    logo_name_with_ext = '{}{}'.format(logo_name, '.png')
    logo_url = '{}/{}'.format(IMAGE_PATH, os.path.join(folder, 
logo_name_with_ext))
    return mark_safe('<img src="{}" height="20" />'.format(logo_url))


The image is uploading in S3 successfully.

But I want to save the same uploaded image's url to database also; inside 
'image_url' column of Brand table.
How can I do that? What change should I make here?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/62af3866-8ab5-4aac-b10c-645e08742e00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to