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

MonitorField with 'when' inits to now? #100

Open
gracebrownecodes opened this issue Jan 6, 2014 · 5 comments
Open

MonitorField with 'when' inits to now? #100

gracebrownecodes opened this issue Jan 6, 2014 · 5 comments

Comments

@gracebrownecodes
Copy link

In my use-case, I have a StatusField with three options and two MonitorFields that use 'when' to watch for a specific status. See abbreviated model below.

When I initialize a new object, it appears that both active_date and deprecated_date are set to the current time. Is this the intended behavior? It would make more sense to me if these MonitorFields were left Null...

class Element(models.Model):
    STATUS = Choices('draft', 'active', 'deprecated')
    status = StatusField()
    created_date = models.DateTimeField('Element creation date', auto_now_add=True, null=False, editable=True)
    active_date = MonitorField('Element active date', monitor='status', when=['active'], null=True)
    deprecated_date = MonitorField('Element deprecation date', monitor='status', when=['deprecated'], null=True)
@carljm
Copy link
Collaborator

carljm commented Jan 6, 2014

Yes, it appears that MonitorField gets a default of now if no other default is given. I think you could easily override this by explicitly providing default=None, but I also would be happy to accept a pull request (with test) that changes the behavior so that if the field is nullable None is the default default.

@gracebrownecodes
Copy link
Author

You're absolutely right, the default=None flag gave the behavior I was looking for. I think my time is better spent trying to remember things like this than submitting a pull request, but thanks for being accepting! And thanks for your speedy and accurate response!

@carljm
Copy link
Collaborator

carljm commented Jan 6, 2014

Great, thanks for the report! I'm going to reopen this because I do think it would be better if MonitorField didn't default to now when nullable. I'm not likely to work on it, but an open ticket communicates more clearly that this change would be welcome if someone gets around to it.

@carljm carljm reopened this Jan 6, 2014
@gracebrownecodes
Copy link
Author

OK, if I happen upon some time I will definitely come back and contribute, as I am enjoying the package.

@iambibhas
Copy link

@carljm something like this would work? iambibhas@a142f24

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

3 participants