On 4/21/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I'm trying to validate fields for a comments app I'm working on. As
> part of the model I have a few non-editable fields, IP address and date.
> Can non-editable fields be validated or even saved when using a
> manipulator?
By "non-editable" I assume you mean those fields have an
editable=False argument.
IIRC the manipulator skips over any fields with editable=False. I
think you can override that by providing the 'follow' argument to the
manupulator.
I think something like this may work, but my memory of this is kind of hazy:
comment_follow = {
'object_id': None,
'content_type': None,
'date': None,
'ipaddr': None,
}
manipulator = comments.AddManipulator(follow=comment_follow)
# then the rest just like you had it
new_data = request.POST.copy()
new_data['object_id'] = object_id
new_data['content_type'] = content_type_id
new_data['date'] = datetime.datetime.now()
new_data['ipaddr'] = request.META.get('REMOTE_ADDR')
#manipulator.do_html2python(new_data)
nc = manipulator.save(new_data)
This will be a lot easier to do at some point. Good luck.
Joseph
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---