One of the features of the Django project that I am writing is sending out a newsletter. I have a model Newsletter
and a function send_newsletter
that I registered to listen to the signal Newsletter
post_save
. When a newsletter object is saved through the administrator’s interface, it send_newsletter
checks to see if created
True is set, and if so, it does send mail.
However, it makes no sense to edit a newsletter that has already been sent, for obvious reasons. Is there a way to make an object Newsletter
read-only after saving it?
Edit:
I know that I can override the method of an save
object to cause an error or to do nothing if the object existed. However, I see no reason to do this. As for the first, I don’t know where to catch this error and how to inform the user that the object was not saved. Regarding the latter, giving the user false feedback (admin interface saying that the saved save) is not like Good Thing.
I really want the user to be able to use the admin interface to write a newsletter and send it, and then view the newsletters that have already been sent. I would like the admin interface to display data for sent newsletters in an uneditable input field without the Save button. Alternatively, I would like the Save button to be inactive.
source
share