DAL 3.10.4rc breaks autocomplete views
ColeDCrawford opened this issue · 5 comments
ColeDCrawford commented
I get errors like this across all my autocompletes after trying the latest RC
TypeError: Object of type Work is not JSON serializable "GET /_autocomplete/work/ HTTP/1.1" 500 138259
bubublik commented
Same error:
raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type ModelName is not JSON serializable
ducdetronquito commented
I encountered the same problem with Python 3.11 and DAL 3.10.4rc
For now I had to downgrade to DAL 3.9.7 to fix the problem.
Here is a way to reproduce it, I hope it helps:
# models.py
from django.db import models
class Workspace(models.Model):
name = models.CharField(max_length=40)
# views.py
from dal import autocomplete
class WorkspaceAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
Workspace.objects.create(name="test to populate DB")
return Workspace.objects.all()
# urls.py
from django.urls import path
urlpatterns = [
path(
"workspace-autocomplete/",
WorkspaceAutocomplete.as_view(),
name="workspace-autocomplete",
),
]
// In a web browser, this GET request should return an error 500
GET http://localhost:8000/workspace-autocomplete/
jpic commented
Please re-open if re-occuring with 3.11.0-rc1
ducdetronquito commented
I tested the 3.11.0-rc1 release in production this morning and the issue has been fixed !
Thanks :=)