Closed rcooke closed 7 months ago
I'm not sure I can follow here. The tests for 3.0.8 pass with Python 3.8/3.9/3.10. Besides, you say that you use Python 3.9, but then you refer to a path which seems to support py310. Can you please add some details?
Oops. Typo fixed in my post. I was so focused on getting the old versions right, I messed up the current one.
It may not be a "problem" in the code - do you run tests with -bb? That was how I found it.
For the record, when I am updating projects to new Python or major package versions, I use these Python flags to dig out hidden problems:
# Enable extended checks, warnings, and DEV mode:
python -bbXdevWalways ./manage.py runserver_plus 0.0.0.0:8000
# Add really verbose logging:
python -vvbbXdevWa ./manage.py test
I got the error when I used the first debug line to run the dev server and tried to load the home page, which has the Dashboard on it. I can access the CRUD interface pages without error.
I am thinking its a change in how the affected function is to be used. Something that used to work fine back in Python 2.7. But with the change to Unicode strings, can actually cause a type-casting problem - possibly really subtle.
No, I do not run tests with -bb
. Besides, I'm not able to use the runserver command you posted (though django-extensions is installed).
You can add those flags to whatever command you do run - instant benefit. I tried to run your tests and got these errors. Is there a setup for tests I am missing?
ERROR grappelli/tests/test_checks.py - django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
ERROR grappelli/tests/test_related.py - django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
ERROR grappelli/tests/test_switch.py - django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Using this environment under Python 3.10:
(py310dj42) rcooke@developer1:~/source/grappelli_master$ pip list
Package Version Editable project location
-------------------- ------------ ------------------------------------
asgiref 3.7.2
attrs 23.1.0
certifi 2023.11.17
Django 4.2.8
django-admin-locking 1.6 /home/rcooke/source/dj_admin_locking
django-appconf 1.0.6
django-debug-toolbar 4.2.0
django-extensions 3.2.3
django-filebrowser 4.0.3
django-grappelli 3.0.8
django-staticfiles 1.2.1
exceptiongroup 1.2.0
feedparser 6.0.11
h11 0.14.0
idna 3.6
iniconfig 2.0.0
MarkupSafe 2.1.3
mysqlclient 2.2.1
outcome 1.3.0.post0
packaging 23.2
Pillow 10.1.0
pip 23.3.2
pluggy 1.3.0
PySocks 1.7.1
pytest 7.4.3
pytz 2023.3.post1
selenium 4.16.0
setuptools 65.5.0
sgmllib3k 1.0.0
simplejson 3.19.2
six 1.16.0
sniffio 1.3.0
sortedcontainers 2.4.0
sqlparse 0.4.4
tomli 2.0.1
trio 0.23.2
trio-websocket 0.11.1
typing_extensions 4.9.0
unicodecsv 0.14.1
urllib3 2.1.0
Werkzeug 3.0.1
wheel 0.42.0
wsproto 1.2.0
Adding the flags results with an error here. I'm running the tests with tox: tox -e py38-django31
Figure it out ... flags work now, but no error with using the dashboard.
interesting....
I don't see any b'...' strings on my dashboard, so I have no idea what the potential problem is. I have not figured out what that code is even doing, or why. I wonder why I get these warnings and the tests don't? I did notice your Dashboard test file was a little light.
I need to add MFA security and get latest bootstrap working in this project - to serve up a public web site in addition to the internal apps they have now. After I get that sorted, I will revisit this. Please leave open so I don't forget.
I'm closing this since I've never been able to reproduce it. Please reopen if you think this issue is still valid.
I am updating an existing project to Django 4.2 and Python 3.10 (Was DJ2.2 on Py3.7). I thought I had resolved all syntax changes etc. But, when I run the project with python -bb I get this error:
/home/rcooke/.pyenv/versions/py310dj42/lib/python3.10/site-packages/grappelli/dashboard/utils.py:113: BytesWarning: str() on a bytes instance
pattern_items.sort(key=lambda x: str(x[0]._meta.verbose_name_plural.encode('utf-8')))
I don't see a note about it, nor is it mentioned in the Release Notes for 3.0.8. Or release notes for 2.15.
This project was originally written for Python 2.7, so this might be something from way back.