You can also do that by overriding the form's __init__ : http://stackoverflow.com/questions/324477/in-a-django-form-how-to-make-a-field-readonly-or-disabled-so-that-it-cannot-be
You can pass the user to init and disable fields depending on that parameter. - Paulo On Sat, Mar 20, 2010 at 4:02 PM, Thierry Chich <thierry.ch...@gmail.com>wrote: > Le samedi 20 mars 2010 16:05:20, Peter Reimer a écrit : > > Hi Folks, > > > > I'm looking for a way to get the following done: > > Depending on different things (user, groups, rights, etc.) I want to > > show a form with fields that can either be changed or not. For > > example, a form with two fields for name and hobby, an admin can > > change both fields, a normal user can only change hobby. > > > > One solution that came to mind: Create a form for both groups and > > exclude in the user's form the fields, he mustn't change. But I want > > two things: > > 1. Show the read-only values at the position where the admin sees the > > writeable fields because a user can be an admin (at another place) and > > it would be confusing to have different positions here and there. > > 2. Have something reusable: E.g. form = MySpecialForm(deactivated = > > [name]). > > > > I checked to docu and googled around, not only some minutes... and > > found nothing. > > Has somebody here a hint for me? I don't want a solution, I'm thankful > > for some little hints. > > > > I am not sure, but for me, you should have something like > <input type=text READONLY value='Do not touch'> > If you want it appear only when you give rights, you could put a condition > in > the template > <input type=text {% if not user.has_perm() %} READONLY {%endif%} value='Do > not > touch if you can't'> > > I don't know if it answer to your question or if you think at something > more > complex. > > Thierry > > Thanks & have a nice weekend > > Peter > > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.