如何解决该问题:没有名为“ multiselectfield”的模块?

时间:2020-07-22 05:26:11

标签: django

我成功安装了django-multiselectfield,但是它不起作用。这些是我运行lib的步骤:

  • pip3安装django-multiselectfield
  • INSTALLED_APPS = [
    #...,
    'multiselectfield'
    ] 另外,我确实创建了requirements.txt文件,但错误没有消失,如何成功安装此lib

models.py

from multiselectfield import MultiSelectField
class PlayerName(models.Model):
    match = models.ForeignKey(Match, on_delete=models.CASCADE, related_name='player_name')
    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name


PLAYERS = PlayerName.objects.values_list('name', 'name')


class PlayerBox(models.Model):
    player_name = models.ForeignKey(PlayerName, on_delete=models.CASCADE, related_name='player_box')
    name = MultiSelectField(choices=PLAYERS)

编辑帖子

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/core/management/__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/home/abdelhamedabdin/.local/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'multiselectfield'

0 个答案:

没有答案