On Nov 26, 8:07 am, vanosten <[EMAIL PROTECTED]> wrote:
> Hi
>
> I need to do custom validation to make sure that a new record does not
> pick the same title as a previous record. Therefore in my overriden
> clean method in my custom Form (which extends ModelForm) I need to be
> able to do either of the following:
> # access the session, where the parent object is saved
> # access the POST request object to access session, to do the same as
> above
> # access the model instance, to get to the parent
>
> How can I do this?

You can access the model instance via form.instance.

To get access to the request, you'll need to pass it in to the form
somehow. The best way is probably to override the form's __init__
method to add a request parameter and save it as self.request - you
can then pick it up in the clean method.

However it's not clear why you need to access the session - there's no
need to do if you just want to do model queries.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to