Malcolm Tredinnick wrote: > On Wed, 2006-10-11 at 15:07 -0500, Patrick J. Anderson wrote: >> I have extended Django User model (site members as opposed to users) and >> I want to approve them before they can use all site features. Below is >> my model: >> >> class Member(models.Model): >> user = models.ForeignKey(User) >> ... >> is_approved - models.NullBooleanField(default = False) >> ... >> >> Now, I want members to use site forms (not admin) to edit their profile >> details. Obviously, I don't want them to approve themselves, so I use >> hidden input value in my form: >> >> <input type="hidden" id="id_is_approved" name="is_approved" value="{{ >> object.is_approved }}" /> > > If you don't want people approving themselves, then this won't stop > them. It is very easy to change the value of even a hidden field in a > form prior to submission Type="hidden" just means it won't display in > the UI. It doesn't mean the user can't change it. > > >> However, whenever a member (even approved member) saves their profile, >> the value of "is_approved" is set to NULL. >> >> By the way, I'm using generic views. I looked at the admin interface >> source for this model type of input code and found this: >> >> <label for="id_is_approved">Approved?:</label> >> <select id="id_is_approved" class="vNullBooleanField" >> name="is_approved" size="1"> >> <option value="1">Unknown</option> >> <option value="2">Yes</option> >> <option value="3">No</option> >> </select> >> >> I assume that the framework translates this into appropriate values >> before saving the record and it works fine using admin interface. >> >> When I looked at the value of {{ object.is_approved }} in my template, >> the value for approved member is "1", and when that profile is saved, >> the value of is_approved changes to NULL. > > It sounds like this part is working correctly, except for putting in the > correct initial value: you have a value of "1" in the form and this is > converted into the NULL case after submission. > > I'm not sure why you are seeing a "1" in the hidden input field. I would > have expected the string "False" to appear, since the value of the field > in your model is going to be None, True or False (and the latter by > default). > > Regards, > Malcolm > > > > > >
I guess the concept of approving members needs to be refined. My project has some "special" requirements and this is one of them. On the value of {{ object.is_approved }}: I see None for "Unknown", 1 for "Yes" and 0 for "No". I'm not sure why either. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---