Created
August 25, 2011 13:25
-
-
Save gileno/1170647 to your computer and use it in GitHub Desktop.
Pegar o IP no form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MeuForm(forms.Form): | |
request = None | |
def __init__(self, request, *args, **kwargs): | |
super(MeuForm, self).__init__(*args, **kwargs) | |
# é importante que na view você não esquece de passar a request para o form se não vai dar erro | |
self.request = request | |
def clean(self): | |
# pegar endereço de IP aqui, sei que isso não funciona | |
client_address = self.request.META['REMOTE_ADDR'] | |
# faz mais coisas | |
super(ValidatingAuthenticationForm, self).clean() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment