Git Product home page Git Product logo

Comments (1)

respondcreate avatar respondcreate commented on August 16, 2024

Hey @honi !

First off, sorry for the delay in response (had a bit of a crazy week). This is a known issue that has to do with how Django's ModelForm fails to detect changes in form fields that subclass MultiValueField (as django-versatileimagefield's admin form fields do). The good news is that there is a super-fast workaround. I'll include it here now (to unblock you) and will add it to the docs sometime within the next week (so other folks can consult the docs when they run into this).

You'll need to do two things:

  1. Create a custom ModelForm that will ALWAYS report that it has changed data.
  2. Integrate that custom ModelForm with your inline.

Creating the custom form that always reports changes

# yourapp/forms.py
from django.forms.models import ModelForm

class AlwaysChangedModelForm(ModelForm):
    """
    Ensures VersatileImageField's inline models ALWAYS get saved so PPOI
    values will make their way into the database.
    """
    def has_changed(self):
        return True

Integrating the custom form into an inline

# yourapp/admin.py

from django.contrib import admin

from .forms import AlwaysChangedModelForm
from .models import YourModel

class YourCustomInline(admin.StackedInline):
    model = YourModel
    form = AlwaysChangedModelForm

Let me know if that works out for you!

from django-versatileimagefield.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.