thanks for the reply Shawn,
the reason why I am not using ModelForm is
in the clean_url() I am using this validation
url=self.cleaned_data['url']
user_given_urls=[x.url for x in
MyModel.objects.filter(creator_of_entry=self.instance.creator_of_entry)]
if url in user_given_urls:
raise forms.ValidationError('duplicate url')
That would not work for a Modelform because creator is not set when
is_valid() is called and so no validation error occurs.
if request.method=='POST' and form.is_valid():
mymdl=form.save()
mymdl.creator_of_entry=request.user
mymdl.save()
Is there some other way to get user_given_urls other than the list
comprehension above?If so please tell me
thanks
mark
On Oct 5, 6:45 pm, Shawn Milochik <[email protected]> wrote:
> Why not just use a ModelForm?
>
> You can override the form's clean() or add a clean_url() method. You'll be
> able to use self.instance to get the model instance of the model form, and
> from that you can get the previously-used URLs.
>
> Shawn
--
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?hl=en.