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

Problem when using it as an inline widget in Admin #9

Open
tanwirahmad opened this issue Jan 28, 2021 · 0 comments
Open

Problem when using it as an inline widget in Admin #9

tanwirahmad opened this issue Jan 28, 2021 · 0 comments

Comments

@tanwirahmad
Copy link

I have recently encountered a problem with the widget when it is used as an inline widget in Admin. The problem is that the django was saving a new record for the inline form containing the widget even if you do not enter any value in that form.

Django 2.2

Workaround: in the value_from_datadict function, we should return a list of None, the IF condition should be like the following and we should return None on ValueError expection:

        if days == 0 and hours == 0 and minutes == 0 and seconds == 0:
            return None

        try:
            D = timedelta(
                days=int(days),
                hours=int(hours),
                minutes=int(minutes),
                seconds=int(seconds)
            )
        except ValueError:
            return None
        else:
            return str(D)
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