On Mon, 2007-04-16 at 08:58 +0000, [EMAIL PROTECTED] wrote:
> 
> I don't think one it's possible to add to the "fields" admin option,
> so you'll end up having all editable fields in it:
> 
> class MyModel()
>     field1 = models.CharField(editable=False)
>     field2 = models.CharField()
>     ...
>     fieldn = models.SomeField()
> 
> Class MyModelAdmin()
>   fields = {"field1", "field2", ... "fieldn"}
> 
> Which is not very DRY, because all fields except field1 would have
> been there anyway.

In the relatively rare case when you want to display a non-editable
field in admin, you might need to list them all. This is part of making
the easy things easy and the harder things possible. I don't see it as
worth it to add a whole extra piece of infratsructure for a relatively
rare situation when you can just list the fields using existing
mechanisms. The act of writing them out *once* in that list won't kill
people.

> Besides, we still need the "readonly_fields" option to make
> editable=True fields readonly in the admin interface. For example:

Why is this needed? The field is marked as *editable*, hence it's not
read-only. The admin app is for trusted users to edit records. If you
want fine-grained control where administrators should not be editing
particular fields that they could edit when they are not administrators,
write a custom form. Even the current admin application allows custom
forms for model editing and newforms-admin will, presumably, as well.

> Class MyModelAdmin()
>   readonly_fields = {"field1", "field42"}
> 
> would made field1 and field42 editable in the add form and readonly in
> the change form. It has the added benefit of being more consistent
> because fields in the "fields" options are editable and fields in
> "readonly_fields" are readonly. Otherwise we end up doing "magic"
> depending on whether a field in "fields" is editable or not.
> 
> I thus propose to update my patch to do the following:
> 1) add a "readonly_fields" options in the admin class
> 2) said option will accept a list of model fields (regardless of their
> editable status), which will be editable in the add form and displayed
> in the change form
> 3) editable = False fields will raise an error when added to the
> regular "fields" list

I think you are trying to graft too much fine-grained control into the
admin app. I don't like this design for that reason. -1 from me.

This whole thread started out as adding support to forms for read-only
fields. That really isn't a hard thing to do. It seem to be have become
overly complicated trying to graft the equivalent of C's "const"
behaviour into form fields, which feels wrong on a number of levels.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to