Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Something is broken with current Django master #752

Closed
IvanAnishchuk opened this issue Oct 23, 2019 · 6 comments
Closed

Something is broken with current Django master #752

IvanAnishchuk opened this issue Oct 23, 2019 · 6 comments

Comments

@IvanAnishchuk
Copy link
Member

Tests fail with Django master branch. It might be a problem with DRF or tests themselves, of course, needs further investigation.

======================================== test session starts ========================================
platform linux -- Python 3.8.0, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
cachedir: .tox/py38-djangomaster/.pytest_cache
Django settings: tests.settings (from environment variable)
rootdir: /home/user/src/django-oauth-toolkit, inifile: tox.ini
plugins: forked-1.1.3, django-3.6.0, cov-2.8.1, xdist-1.30.0
collected 217 items / 1 errors / 216 selected                                                       

============================================== ERRORS ===============================================
___________________________ ERROR collecting tests/test_rest_framework.py ___________________________
ImportError while importing test module '/home/user/src/django-oauth-toolkit/tests/test_rest_framework.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/settings.py:177: in import_from_string
    return import_string(val)
.tox/py38-djangomaster/lib/python3.8/site-packages/django/utils/module_loading.py:17: in import_string
    module = import_module(module_path)
.tox/py38-djangomaster/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
    ???
<frozen importlib._bootstrap>:991: in _find_and_load
    ???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:671: in _load_unlocked
    ???
<frozen importlib._bootstrap_external>:783: in exec_module
    ???
<frozen importlib._bootstrap>:219: in _call_with_frames_removed
    ???
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/renderers.py:23: in <module>
    from rest_framework import VERSION, exceptions, serializers, status
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/serializers.py:24: in <module>
    from django.db.models.fields import FieldDoesNotExist
E   ImportError: cannot import name 'FieldDoesNotExist' from 'django.db.models.fields' (/home/user/src/django-oauth-toolkit/.tox/py38-djangomaster/lib/python3.8/site-packages/django/db/models/fields/__init__.py)

During handling of the above exception, another exception occurred:
tests/test_rest_framework.py:12: in <module>
    from rest_framework.test import APIRequestFactory, force_authenticate
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/test.py:138: in <module>
    class APIRequestFactory(DjangoRequestFactory):
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/test.py:139: in APIRequestFactory
    renderer_classes_list = api_settings.TEST_REQUEST_RENDERER_CLASSES
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/settings.py:220: in __getattr__
    val = perform_import(val, attr)
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/settings.py:168: in perform_import
    return [import_from_string(item, setting_name) for item in val]
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/settings.py:168: in <listcomp>
    return [import_from_string(item, setting_name) for item in val]
.tox/py38-djangomaster/lib/python3.8/site-packages/rest_framework/settings.py:180: in import_from_string
    raise ImportError(msg)
E   ImportError: Could not import 'rest_framework.renderers.MultiPartRenderer' for API setting 'TEST_REQUEST_RENDERER_CLASSES'. ImportError: cannot import name 'FieldDoesNotExist' from 'django.db.models.fields' (/home/user/src/django-oauth-toolkit/.tox/py38-djangomaster/lib/python3.8/site-packages/django/db/models/fields/__init__.py).


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================= 1 error in 3.38s ==========================================
ERROR: InvocationError for command /home/user/src/django-oauth-toolkit/.tox/py38-djangomaster/bin/pytest --cov=oauth2_provider --cov-report= --cov-append (exited with code 2)
______________________________________________ summary ______________________________________________
ERROR:   py38-djangomaster: commands failed

@lingster
Copy link

lingster commented Oct 28, 2019

is it possibly caused by this: https://docs.djangoproject.com/en/dev/releases/3.1/?

The compatibility import of django.core.exceptions.FieldDoesNotExist in django.db.models.fields is removed.

so we'd have to update 3rd party packages by replacing:
from django.db.models.fields import FieldDoesNotExist
with
from django.core.exceptions import FieldDoesNotExist

@n2ygk
Copy link
Member

n2ygk commented Mar 17, 2020

these tests appear to be working at present. Please reopen if I am mistaken.

@n2ygk n2ygk closed this as completed Mar 17, 2020
@n1k0
Copy link

n1k0 commented May 18, 2020

I've just tried upgrading to Django 3.1a this morning on a project previously using Django 3.0.6 and I'm getting this error wrt the autoslug package:

Traceback (most recent call last):
  File "./manage.py", line 21, in <module>
    main()
  File "./manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/niko/work/akei/access4all/erp/models.py", line 4, in <module>
    from autoslug import AutoSlugField
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/autoslug/__init__.py", line 12, in <module>
    from autoslug.fields import AutoSlugField
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/autoslug/fields.py", line 30, in <module>
    from autoslug.settings import slugify, autoslug_modeltranslation_enable
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/autoslug/settings.py", line 71, in <module>
    slugify = get_callable(slugify_function_path)
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/urls/utils.py", line 28, in get_callable
    mod = import_module(mod_name)
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/autoslug/utils.py", line 17, in <module>
    from django.db.models.fields import FieldDoesNotExist, DateField
ImportError: cannot import name 'FieldDoesNotExist' from 'django.db.models.fields' (/home/niko/.local/share/virtualenvs/access4all-hL0YrbZN/lib/python3.7/site-packages/django/db/models/fields/__init__.py)

I don't think Django should break imports like that with a large part of the current ecosystem relying on them. Just my opinion though. For now the solution for me is to keep using 3.0.6.

Edit: Woops sorry I thought I was on the Django repository. Will file an issue there. Sorry for the noise.

@colinschwegmann
Copy link

colinschwegmann commented Aug 4, 2020

@n1k0 Did you submit that issue? I am having troubles tracking it in Django's issues. I have the same breaking issue.

@Karikari
Copy link

Karikari commented Aug 6, 2020

having the same issure

@n1k0
Copy link

n1k0 commented Aug 6, 2020

@colinschwegmann nope, couldn't figure how to do it on their Track instance. Meanwhile, the culprit package in my case has been updated to fix the issue. I guess now 3.1 stable is released, all other packages relying on importing django.db.models.fields.FieldDoesNotExist will have to issue a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants