readonly_fields

14 views
Skip to first unread message

tony gair

unread,
Jun 19, 2013, 9:08:11 AM6/19/13
to django...@googlegroups.com

I have tried to use readonly_fields in a form to designate fields that the user is not allowed to change.

class Meta 
        readonly_fields = [user]
e.g.


However when I show the form the user can edit them.....doh, btw I do want to display, but not to edit!

Timster

unread,
Jun 19, 2013, 9:26:08 AM6/19/13
to django...@googlegroups.com
Where are you setting that? readonly_fields is for ModelAdmin when you are working with the admin app.

If you want to do it in a normal form, you will need to set readonly attribute on the widget.

tony gair

unread,
Jun 19, 2013, 9:37:41 AM6/19/13
to django...@googlegroups.com
Ah thanks that explains that.... I'll look into changing the readonly attribute on the widget, is there a list of widgets do you know as some of these are choice fields i.e. non text and non integer fields


On Wed, Jun 19, 2013 at 1:26 PM, Timster <timsha...@gmail.com> wrote:
Where are you setting that? readonly_fields is for ModelAdmin when you are working with the admin app.

If you want to do it in a normal form, you will need to set readonly attribute on the widget.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/SEWttelj3h0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Timster

unread,
Jun 19, 2013, 11:02:36 AM6/19/13
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages