Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Object of type ImageFieldFile is not JSON serializable #1445

Open
AlexandrKovin opened this issue Jan 28, 2025 · 0 comments
Open

Comments

@AlexandrKovin
Copy link

Describe the bug

class Product(AbstractProduct):

    name = models.CharField(
        max_length=500, verbose_name='Product', unique=True
    )

    default_photo_url = models.ImageField(
        max_length=500,
        storage=S3Boto3Storage(),
        upload_to=product_upload_to_default,
    )

    is_active = models.BooleanField(default=True, null=False)

    history = HistoricalRecords(
        bases=[
            DiffsHistoricalModel,
        ]

    )

A historical model is being created. The default_photo_url field becomes a TextField. And when saving the product model an error occurs

File /lib/python3.11/site-packages/simple_history/models.py", line 662, in post_save
    self.create_historical_record(instance, created and "+" or "~", using=using)
  File lib/python3.11/site-packages/simple_history/models.py", line 780, in create_historical_record
    history_instance.save(using=using)
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type ImageFieldFile is not JSON serializable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant