Saturday, February 26, 2022

Re: How to compare two image field properly

one way that i know, not sure if best way to do it, 
but you could first extract the fields of your model as:
`modelAFields =  ModelA._meta.fields`
`modelBFields =  ModelB._meta.fields`

then extract your image field eg.:
`imageAField = modelAFields[0]`
`imageBField = modelBFields[0]`

then to display all the field's atributes and loop through them for comparing by :
`vars(imageAField)`
`vars(imageBField)`

Regards, Azzam.




On Tuesday, February 22, 2022 at 12:16:42 AM UTC+8 sencer...@gmail.com wrote:
Thanks but, no.
I didn't mean the comparing content of the files.

19 Şub 2022 Cmt 21:55 tarihinde <tlockh...@gmail.com> şunu yazdı:
OpenCV

- Tom

On Feb 19, 2022, at 2:27 AM, Sencer Hamarat <sencer...@gmail.com> wrote:


Hi,

I have two different models which include image fields individually.

Is there a proper way to compare those imagefileds?

class ModelA(models.Model):
    file = models.ImageField(
        verbose_name=_('File'),
        blank=False,
        null=False,
        max_length=400
    )

class ModelB(models.Model):
    image = ImageField(
        verbose_name=_('Product Image'),
        max_length=400,
        default=static('images/default_thumbnail.png'),
    )


Also, I need to figure out how to track any change in a single image field.

Regards,
Sencer HAMARAT

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACp8TZhoLKhfpdn7UcrWajf%2BZ8snaNvFB8M29p4nF5eZ2f7iEg%40mail.gmail.com.

--
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...@googlegroups.com.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8ab6fcee-6851-4b02-bb1f-edc02bfd2d32n%40googlegroups.com.

No comments:

Post a Comment