On Saturday, September 7, 2024 at 5:45:59 PM UTC+4 Ryan Nowakowski wrote:
On September 5, 2024 9:06:38 PM CDT, Asoma Samuel <samuela...@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/87365402-38e5-421d-9361-9843fa3b729en%40googlegroups.com.
No comments:
Post a Comment