1👍
The comments framework provides a comment_will_be_posted
signal:
http://docs.djangoproject.com/en/1.2/ref/contrib/comments/signals/#comment-will-be-posted
If you register at this signal, your handler will be passed the (not yet saved) comment object and the request as arguments. If your handler returns False, the post_comment
view answers with CommentPostBadRequest
, as it does on any other sort of error like failed form validation.
- [Django]-How can I set arbitrary attributes on Django Model Fields, then access them in a ModelForm?
0👍
One possible way, but you still do not have request object in this level of validation…
class SomeForm(forms.ModelForm):
somefield = forms.CharField(...)
def check_somefield(self):
somefield = self.cleaned_data['somefield']
... #do what you want
return somefield
Hope this can help, or i do not understand what you want correctly.
- [Django]-'Cannot alter upload handlers' while trying to upload file
- [Django]-Default Django Admin Forms and FormWizard
- [Django]-Hiding save buttons in admin if all fields are read only
- [Django]-Get method classname inside decorator at __init__ in python
- [Django]-Django over https form redirection issues
0👍
I think this is the answer to your question:
How do I access the request object or any other variable in a form's clean() method?
- [Django]-How to populate database fields when model changes in django
- [Django]-Urls.py redirect with URL reversal and parameters — is there any easier way?
Source:stackexchange.com