Why does django throw TypeError when sending requests through Apache WSGI?

528 views
Skip to first unread message

Kyle Paterson

unread,
Dec 8, 2021, 8:59:55 AM12/8/21
to Django users
Started a new project after not using Django for roughly two years, works fine when running as a development server but throws TypeError: SimpleLazyObject class: property object not callable.

From apache error log:
[Wed Dec 08 10:11:53.023239 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946] Traceback (most recent call last):
[Wed Dec 08 10:11:53.023283 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]   File "/home/kyle/active-travel/traveldata/traveldata/wsgi.py", line 14, in <module>
[Wed Dec 08 10:11:53.023327 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]     from django.core.wsgi import get_wsgi_application
[Wed Dec 08 10:11:53.023351 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]   File "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
[Wed Dec 08 10:11:53.023371 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]     from django.utils.version import get_version
[Wed Dec 08 10:11:53.023377 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]   File "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/version.py", line 7, in <module>
[Wed Dec 08 10:11:53.023430 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]     from django.utils.regex_helper import _lazy_re_compile
[Wed Dec 08 10:11:53.023435 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]   File "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/regex_helper.py", line 10, in <module>
[Wed Dec 08 10:11:53.023524 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]     from django.utils.functional import SimpleLazyObject
[Wed Dec 08 10:11:53.023529 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]   File "home/kyle/active-travel/venv/lib/python3.8/site-packages/django/utils/functional.py", line 364, in <module>
[Wed Dec 08 10:11:53.023578 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]     class SimpleLazyObject(LazyObject):
[Wed Dec 08 10:11:53.023611 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946] TypeError: Error when calling the metaclass bases
[Wed Dec 08 10:11:53.023613 2021] [wsgi:error] [pid 10704:tid 140343150348032] [remote 127.0.0.1:44946]     'property' object is not callable

Apache site config file:
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
       
        Alias /static /home/kyle/active-travel/traveldata/static
                <Directory /home/kyle/active-travel/active_travel/static>
                        Require all granted
                </Directory>

        <Directory /home/kyle/active-travel/traveldata>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIScriptAlias / /home/kyle/active-travel/traveldata/traveldata/wsgi.py process-group=traveldata
        WSGIDaemonProcess traveldata python-home=/home/kyle/active-travel/venv python-path=/home/kyle/active-travel/traveldata/traveldata
        WSGIProcessGroup traveldata

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        LogLevel info

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

Django project wsgi.py:
import os, sys
sys.path.append('home/kyle/active-travel/venv/lib/python3.8/site-packages')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'traveldata.settings')
application = get_wsgi_application()

As you can see, all fairly standard, Debug set to true, no changes to standard content of site, followed the documentation instructions to run requests through apache and mod_wsgi. Suspect the issue is with Django but not entirely certain.
Please help.
Thanks, Kyle

Sencer Hamarat

unread,
Dec 8, 2021, 10:07:11 AM12/8/21
to django...@googlegroups.com
Hi,

I think this is not related with apache

It seems like class object property is called as a method somehow.
Unfortunately the error does not reveal the property name.

Regards,
Sencer HAMARAT



--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5f2afc8d-ce62-4af8-9c2d-b43692530974n%40googlegroups.com.

Jason

unread,
Dec 9, 2021, 7:51:18 AM12/9/21
to Django users

with your settings usage, are you defining a property in settings and trying to use it anywhere?

furthermore, are you using settings via 

from traveldata.traveldata import settings (example)

or via

from django.conf import settings

The latter is the recommended means because settings are lazy loaded.

Kyle Paterson

unread,
Dec 15, 2021, 5:03:27 AM12/15/21
to django...@googlegroups.com
I am not using either of those, I think. The only place I explicitly load settings is in wsgi.py, with the line:
os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘travel data.settings'

You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/kiKnMKVC7AY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1ff9d508-a42b-4d1c-a2f3-6124fe69e556n%40googlegroups.com.

Kyle Paterson

unread,
Dec 15, 2021, 10:06:00 AM12/15/21
to Django users
Used libapache2-mod-wsgi-py3 instead of python 2 version
Reply all
Reply to author
Forward
0 new messages