If you want the request in a form, you need to supply it.

You can use the code you posted - but then when you create the form - you
need to add the request.

Something like:

form = Form(request=request)

every time you init the form - then it will work for you.

Regards,

Andréas

2018-04-27 16:07 GMT+02:00 James Farris <[email protected]>:

> This should work
>
> https://github.com/un33k/django-ipware/blob/master/README.md
>
>
> On Fri, Apr 27, 2018 at 5:45 AM lakshitha kumara <[email protected]>
> wrote:
>
>> Hello Andréas
>>
>> Thank for your reply. but unfortunately i need get user ip on form.py or
>> custom py file in django. is there way to to that ?
>>
>> Some one post on this example can be work but its also doesn't work
>>
>> class RegistrationForm(UserCreationForm):
>>
>>     def __init__(self, *args, **kwargs):
>>         self.request = kwargs.pop('request')
>>         super(RegistrationForm, self).__init__(*args, **kwargs)
>>
>> On Friday, April 27, 2018 at 6:06:36 PM UTC+5:30, Andréas Kühne wrote:
>>
>>> Hi,
>>>
>>> You can get the IP address from the request. See here:
>>> https://stackoverflow.com/questions/4581789/how-do-i-
>>> get-user-ip-address-in-django
>>>
>>> Regards,
>>>
>>
>>> Andréas
>>>
>>> 2018-04-27 14:28 GMT+02:00 lakshitha kumara <[email protected]>:
>>>
>> Hello Guys
>>>>
>>>> Is there way to get current user ip address on form.py
>>>>
>>>> Thanks
>>>>
>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>>
>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>
>>>
>>>> Visit this group at https://groups.google.com/group/django-users.
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%
>>>> 40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/d7edf4df-90c5-4b48-afd5-a31fd157d2f2%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/
>> msgid/django-users/f82200e2-f329-450e-a8a0-1eaf2dc07bc2%
>> 40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/f82200e2-f329-450e-a8a0-1eaf2dc07bc2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAE-E-_2DwSfmnLNbDh2tge9gHxkUMHMyOWfM
> oj7Ep20k3LuX4w%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE-E-_2DwSfmnLNbDh2tge9gHxkUMHMyOWfMoj7Ep20k3LuX4w%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCez4%2BCCjsiczsnK%2BvM1p-DnjN0fyL374f0Y4DHC6drJHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to