Skip to content

models: Add explicit app_label

Explicitely set app_label to models in order to avoid import errors when using sphinx autodoc.

WARNING: autodoc: failed to import module 'urls' from module 'swh.deposit'; the following exception was raised:
Traceback (most recent call last):
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/sphinx/ext/autodoc/importer.py", line 71, in import_module
    return importlib.import_module(modname)
  File "/usr/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/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/urls.py", line 40, in <module>
    url(r"^1/", include("swh.deposit.api.urls")),
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/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/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/api/urls.py", line 14, in <module>
    from .collection import CollectionAPI
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/api/collection.py", line 11, in <module>
    from ..models import Deposit
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/swh/deposit/models.py", line 32, in <module>
    class Dbversion(models.Model):
  File "/home/anlambert/swh/swh-environment/swh-docs/.tox/sphinx-dev/lib/python3.7/site-packages/django/db/models/base.py", line 111, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class swh.deposit.models.Dbversion doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

The label is the same as before so no migration is required.

swh) ✔ ~/swh/swh-environment/swh-deposit [models-explicit-app-label L|✔] 
15:26 $ python3 swh/deposit/manage.py makemigrations
/home/anlambert/.virtualenvs/swh/lib/python3.7/site-packages/jose/backends/cryptography_backend.py:18: CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead
  from cryptography.utils import int_from_bytes, int_to_bytes
No changes detected

Migrated from D5562 (view on Phabricator)

Merge request reports