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

Clearing FileField don't work #326

Open
mireq opened this issue Oct 27, 2022 · 0 comments
Open

Clearing FileField don't work #326

mireq opened this issue Oct 27, 2022 · 0 comments

Comments

@mireq
Copy link
Contributor

mireq commented Oct 27, 2022

Cleared ImageField / FileField returns False as value.

This code assigns False to model field. This saves 'False' to database field.

for field, value in model_fields.items():
try:
setattr(translation, field, value)
except TypeError:

Django uses following code to convert False to delete action:

https://github.com/django/django/blob/e03cdf76e78ea992763df4d3e16217d298929301/django/forms/models.py#L84-L85

This issue can be fixed with this code:

for field, value in model_fields.items():
    try:
        model_field = parler_meta.model._meta.get_field(field)
        model_field.save_form_data(translation, value)
DrMeers added a commit to DrMeers/django-parler that referenced this issue Apr 18, 2024
DrMeers added a commit to DrMeers/django-parler that referenced this issue Apr 19, 2024
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