Saturday, April 28, 2012

Edit-once object in admin?

I've got a model that looks something like this:

class Image(Model):
    name = CharField(max_length=40)

class ImageVersion(Model):
    image = ForeignKey(Image)
    upload_date = DateTimeField(auto_now_add=True)
    data = ImageField(upload_to="images/learncms")

I want all the data in an ImageVersion to be read-only once it is created.  The idea is that the active version of an image is always the latest one, and the only way to change an image is to upload a new version.  Existing versions can never be changed.  How can I implement this in the admin?

--
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/-/8S3EkzfiiBwJ.
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