Saturday, September 7, 2024

Re: Unable to send activation email. user authentication

On September 5, 2024 9:06:38 PM CDT, Asoma Samuel <samuelasoma393@gmail.com> wrote:

>I've overridden socket.getfqdn to return a specific local hostname in my
>Django settings, but this results in the following error when running
>python manage.py runserver:
>javascript
>Copy code
>TypeError: getfqdn() takes 0 positional arguments but 1 was given
>
>When I comment out the override, the server starts without issues, but I'm
>unable to test email sending. Here's the relevant part of my code:
>python
>Copy code
>import socket # Override the local hostname used by Django for sending
>emails EMAIL_HOST_LOCALNAME = 'localhost' socket.getfqdn = lambda:
>EMAIL_HOST_LOCALNAME


getfqdn takes an argument[1] so your monkeypatch needs to take an argument:

original_getfqdn = socket.getfqdn

def my_getfqdn(name=None):
if name is None:
return EMAIL_HOST_LOCALNAME
else:
return original_getfqdn(name)

socket.getfqdn = my_getfqdn

[1] https://docs.python.org/3/library/socket.html#socket.getfqdn

--
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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/48F04FFE-31CD-41E0-B1B7-E073E1EAC933%40fattuba.com.

No comments:

Post a Comment