Robin,

I don't know if this is a 'right' way, but I posted a snippet on
djangosnippets with my DisplayModelForm [1].
Basically, it allows you to reuse your form definitions, but turn them
into a "display_only" mode. You can do all fields or just a few.
I use it to display objects to users, with an edit button, which shows
the same object, but this time in the normal ModelForm way. The
advantage is that the layout is more or less the same for the user,
and for me that I can reuse my form definitions and my templates for
both.
I have put this inside a bunch of custom crud views, because I needed
this same pattern for a lot of objects.
Obviously, using the newforms machinery to just display an object is
not exactly efficient, but for me that is not an issue.

Hope this helps,

Koen

[1]: http://www.djangosnippets.org/snippets/758/

On 15 mei, 15:37, Robin Becker <[EMAIL PROTECTED]> wrote:
> I have a colleague who wishes to restrict the editability of fields 
> dynamically.
> I can see how this arises by considering a Person object. The supervisor role
> might be allowed to edit more than the individual concerned.
>
> We looked in vain for an 'easy' way to do this using old forms, newforms,
> generic views etc etc, but eventually started writing our own views to do 
> this.
>
> Sure I could probably start trying to grok the inner horrors of update_object
> and minulators etc etc, but that seems really overkill for such a simple
> requirement.
>
> I expected to be able to pass in a list of fields that were to be left alone 
> or
> something as easy. Is there no easy way to do these simple extensions; if not
> what's the 'right' way to do this in the various contexts?
> --
> Robin Becker
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to