On 1/18/07, Philipp Keller <[EMAIL PROTECTED]> wrote:
> I think it's quite important to have the opportunity to say "I don't want
> this field to appear in any of my forms" but on the other hand, you may want
> to suppress this fields in the admin.
>
> I think if I wouldn't know anything of django and would look at
> editable=False in the model, I'd think it would affect all forms, not just
> the admin forms.
> For the admin, the settings usually go into the admin-metaclass. In fact
> there is a setting in the admin metaclass to control the fieldSETs but not
> the appearing fields.
>
> I can think of two possible solutions:
>
> a) have an extra parameter editable_admin=False (although this is quite ugly
> and isn't backwards compatible)
> b) have a new admin metaclass "option" in the form of
> class Admin:
> editable = [list of all fields to show up in admin]
Here's an idea that's a bit cleaner, thanks to the newforms-admin branch...
In that branch, the Admin options class has a new hook,
formfield_for_dbfield(). This takes a database Field instance and
returns the newforms Field instance, so you can use it to implement
admin-specific editable stuff:
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'my_uneditable_field':
return None # No form field
return super(MyAdminClass,
self).formfield_for_dbfield(db_field, **kwargs)
The remaining question, then, is whether form_for_model should *not*
create formfields for database fields with editable=False. Judging by
people's comments in this thread, it seems like that's a no-brainer --
if editable=False, then the form_for_model form should not include the
field.
If there aren't any other thoughts on this, let's go ahead and update
the ticket using our slick new triage process. :-)
Adrian
--
Adrian Holovaty
holovaty.com | djangoproject.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---