Thursday, November 1, 2012

Re: Easy way to make all form fields read only?

I would suggest you adding Boolean field to your UserProfile model like is_authorized = models.BooleanField(default=False)

and then in the templates do something like:

{% if user.is_authorized %}

<!-- Show the form here -->

{% else %}

<!-- Show the information here -->



On Thu, Nov 1, 2012 at 9:09 AM, Elena Williams <ele.wil@gmail.com> wrote:
I was also going to suggest using crispy forms -- having used it on a recent project I'd strongly recommend it (it's great when it's plugged in to  existing stylings such as: uni-form or bootstrap).

I've used it with ModelForm using Layout() and Field() and it works a treat.

---
Elena :)
@elequ
04022 90172



On Thu, Nov 1, 2012 at 7:29 AM, Paul <peebor@gmail.com> wrote:
I used to invest something similar; i wanted to to built a read view next to an update view that looks identical except for that read is obviously read-only. I used crispy-forms to do just that; recently an UneditableField (Layout) was added next to Field.
You do however either need to enumerate the model fields in a layout
Paul Bormans

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/5av7W0YQoS8J.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



--
Thanks & Regards
----------------------------

Amyth [Admin - Techstricks]
Email - aroras.official@gmail.com, admin@techstricks.com
Twitter - @mytharora
http://techstricks.com/

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment