[Django] #34299: 'builtin_function_or_method' object has no attribute 'split' error in sql/query

86 views
Skip to first unread message

Django

unread,
Jan 27, 2023, 7:55:52 PM1/27/23
to django-...@googlegroups.com
#34299: 'builtin_function_or_method' object has no attribute 'split' error in
sql/query
-------------------------------------+-------------------------------------
Reporter: stuchalk | Owner: nobody
Type: | Status: new
Uncategorized |
Component: Database | Version: 4.1
layer (models, ORM) | Keywords:
Severity: Normal | builtin_function_or_method, split
Triage Stage: | error
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Doing the follow search I get the error in the summary:


{{{
def search(request):
""" search of the unit strings """
term = request.GET.get("q")
if term:
strngs = Strngs.objects.filter(string=term).values_list(id,
flat=True)
if strngs:
units =
Units.objects.select_related('representations').get(representations__strng_id__in=strngs)
if len(units) == 1:
unit = units[0]
return redirect('/units/view/' + str(unit.id))
else:
return render(request, "../templates/search.html",
{'units': units, 'term': term})
else:
return redirect('/')
else:
return redirect('/')
}}}

The trackback is as follows:


{{{
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/search?q=amp

Django Version: 4.1.5
Python Version: 3.10.9
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'calculations',
'dashboard',
'units',
'unitsystems',
'repsystems',
'constants',
'umisconfig',
'charts']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback (most recent call last):
File "/Users/n00002621/.local/share/virtualenvs/nist_umis-
6UcDd8EB/lib/python3.10/site-packages/django/core/handlers/exception.py",
line 55, in inner
response = get_response(request)
File "/Users/n00002621/.local/share/virtualenvs/nist_umis-
6UcDd8EB/lib/python3.10/site-packages/django/core/handlers/base.py", line
197, in _get_response
response = wrapped_callback(request, *callback_args,
**callback_kwargs)
File "/Users/n00002621/PycharmProjects/nist_umis/units/views.py", line
95, in search
strngs = Strngs.objects.filter(string=term).values_list(id, flat=True)
File "/Users/n00002621/.local/share/virtualenvs/nist_umis-
6UcDd8EB/lib/python3.10/site-packages/django/db/models/query.py", line
1330, in values_list
clone = self._values(*_fields, **expressions)
File "/Users/n00002621/.local/share/virtualenvs/nist_umis-
6UcDd8EB/lib/python3.10/site-packages/django/db/models/query.py", line
1293, in _values
clone.query.set_values(fields)
File "/Users/n00002621/.local/share/virtualenvs/nist_umis-
6UcDd8EB/lib/python3.10/site-packages/django/db/models/sql/query.py", line
2437, in set_values
self.add_fields(field_names, True)
File "/Users/n00002621/.local/share/virtualenvs/nist_umis-
6UcDd8EB/lib/python3.10/site-packages/django/db/models/sql/query.py", line
2143, in add_fields
name.split(LOOKUP_SEP), opts, alias, allow_many=allow_m2m

Exception Type: AttributeError at /search
Exception Value: 'builtin_function_or_method' object has no attribute
'split'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34299>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 27, 2023, 8:43:55 PM1/27/23
to django-...@googlegroups.com
#34299: 'builtin_function_or_method' object has no attribute 'split' error in
sql/query
-------------------------------------+-------------------------------------
Reporter: stuchalk | Owner: nobody
Type: Uncategorized | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
builtin_function_or_method, split | Unreviewed
error |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => invalid


Comment:

You have a typo in your code: `values_list(id, flat=True)` is missing
quotes around "id". In the future, please use
TicketClosingReasons/UseSupportChannels to confirm a bug in Django before
creating a ticket here. Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/34299#comment:1>

Django

unread,
Jan 28, 2023, 4:45:00 AM1/28/23
to django-...@googlegroups.com
#34299: 'builtin_function_or_method' object has no attribute 'split' error in
sql/query
-------------------------------------+-------------------------------------
Reporter: Stuart Chalk | Owner: nobody

Type: Uncategorized | Status: closed
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
builtin_function_or_method, split | Unreviewed
error |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Stuart Chalk):

Darn, so sorry for reporting such a simple coding error.

--
Ticket URL: <https://code.djangoproject.com/ticket/34299#comment:2>

Reply all
Reply to author
Forward
0 new messages