With regard to the error about the introduction of modules in the same directory, the custom module cannot be read by django,2.0 's setting.pyri installed _ APPS?

clipboard.png

sys.path.insert(0,BASE_DIR)
,
sys.path.insert(0,os.path.join(BASE_DIR, "db_tools"))
sys.path.insert(0,os.path.join(BASE_DIR, "apps"))
sys.path.insert(0,os.path.join(BASE_DIR, "extra_apps"))

clipboard.png
:
shell

from goods.models import Goods

:
python models.py:
Traceback (most recent call last):
File "models.py", line 6, in


ModuleNotFoundError: No module named "goods"
django,2.0setting.pyINSTALLTED_APPS
clipboard.png


clipboard.png

clipboard.png `"

    Return the django-filters `FilterSet` used to filter the queryset.
    """
    filter_class = getattr(view, "filter_class", None)
    filter_fields = getattr(view, "filter_fields", None)
    if filter_class:
        filter_model = filter_class.Meta.model ...
        
        assert issubclass(queryset.model, filter_model), \
            "FilterSet model %s does not match queryset model %s" % \
            (filter_model, queryset.model)
        return filter_class

Local vars`


look at the screenshot above + my own conjecture, understand as follows:

  1. according to your quote, goods should be a package? That is, there is a _ _ init__.py under the directory.
  2. There is a module models under
  3. goods, and a class Goods in models .
  4. create a new _ _ init__.py in the apps root directory, that is, apps is also a package
  5. models.py modified to
sys.path.append("../..")
from apps.goods.models import MyGoods
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b33364-2be91.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b33364-2be91.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?