Monday, September 3, 2012

Django admin forms - using a different/unconventional widget for a field

Hi,

I have a DateTimeField in my model but I want to show with a CheckboxInput.

We have a DateTime field in the model because we want to save the datetime when the instance was cancelled but we dont want the user to see that and just check or uncheck the cancellation checkbox.

I already overrode the save method of the form to transform the boolean of the checkbox into datetime.now() but I also need the vice-versa: to show the checkbox checked or unchecked according to the presence or not of a date.

How can I do that?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/dzV_9mxKvWsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment