Я новичок ie Обучение django Я поражен здесь, может кто-нибудь помочь в этом.
Я следил за этим руководством https://www.youtube.com/watch?v=RMTVAIVrdtM Я использую pycharm IDE, созданный на аналогичной строки, но я все еще получаю сообщение об ошибке.
from poll import view as poll_views ### Getting error in this line .....----<<<<<<<
urlpatterns = [
path('admin/', admin.site.urls),
path(''.poll_views.home,name='home'),
path('create/'.poll_views.create, name='create'),
path('vote/<poll_id>'.poll_views.vote, name='vote'),
path('results/<poll_id>'.poll_views.results, name='results'),
]
views.py
from django.shortcuts import render
# Create your views here.
def home(request):
context = {}
return render(request, 'poll/home.html',context)
def create(request):
context = {}
return render(request, 'poll/create.html',context)
def vote(request, poll_id):
context = {}
return render(request, 'poll/vote.html',context)
def results(request, poll_id):
context = {}
return render(request, 'poll/results.html',context)
На терминале
(test) C:\Users\Learner\projects\poll_project>python manage.py migrate
Traceback (most recent call last):
File "C:\Users\Learner\projects\poll_project\manage.py", line 21, in <module>
main()
File "C:\Users\Learner\projects\poll_project\manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\base.py", line 366, in execute
self.check()
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = self._run_checks(
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\commands\migrate.py", line 64, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\Learner\Envs\test\lib\site-packages\django\urls\resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\Users\Learner\Envs\test\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Learner\Envs\test\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "c:\users\Learner\appdata\local\programs\python\python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1021, in _gcd_import
File "<frozen importlib._bootstrap>", line 998, in _find_and_load
File "<frozen importlib._bootstrap>", line 977, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Learner\projects\poll_project\poll_project\urls.py", line 19, in <module>
from poll import view as poll_views
ImportError: cannot import name 'view' from 'poll' (C:\Users\Learner\projects\poll_project\poll\__init__.py)
Найдите скриншот папки проекта ниже.
это моя структура папок
Может ли кто-нибудь помочь мне, где я ошибаюсь ???