Форум сайта python.su
Добрый день!
Прошу помощи у профессионалов, так как сама разобраться не в силах…
Создаю свой первый проект на Джанго, с питоном так же “знакома не давно”, потому за глупые вопросы извиняюсь заранее. При попытке в терминале выполнить миграцию, вылазиет ошибка, но что не так не пойму… на урлы мои ругается что ли… после всех манипуляций еще и сервер перестал запускаться….
Прилагаю ответ в терминале:
(venv) vladimir@vladimir-B85M-D2V:~/public.html$ python manage.py migrate
Traceback (most recent call last):
File “manage.py”, line 10, in <module>
execute_from_command_line(sys.argv)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/__init__.py”, line 367, in execute_from_command_line
utility.execute()
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/__init__.py”, line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 305, in run_from_argv
self.execute(*args, **cmd_options)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 353, in execute
self.check()
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 385, in check
include_deployment_checks=include_deployment_checks,
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/commands/migrate.py”, line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 372, in _run_checks
return checks.run_checks(**kwargs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/registry.py”, line 81, in run_checks
new_errors = check(app_configs=app_configs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 14, in check_url_config
return check_resolver(resolver)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 24, in check_resolver
for pattern in resolver.url_patterns:
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 310, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 303, in urlconf_module
return import_module(self.urlconf_name)
File “/home/vladimir/public.html/venv/lib/python3.5/importlib/__init__.py”, line 126, in import_module
return _bootstrap._gcd_import(name, package, level)
File “<frozen importlib._bootstrap>”, line 986, in _gcd_import
File “<frozen importlib._bootstrap>”, line 969, in _find_and_load
File “<frozen importlib._bootstrap>”, line 958, in _find_and_load_unlocked
File “<frozen importlib._bootstrap>”, line 673, in _load_unlocked
File “<frozen importlib._bootstrap_external>”, line 665, in exec_module
File “<frozen importlib._bootstrap>”, line 222, in _call_with_frames_removed
File “/home/vladimir/public.html/futbolkas/urls.py”, line 6, in <module>
url(r'^$', ‘main.views.home’),
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/conf/urls/__init__.py”, line 85, in url
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
(venv) vladimir@vladimir-B85M-D2V:~/public.html$ python manage.py runserverPerforming system checks…
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7ff4165147b8>
Traceback (most recent call last):
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/autoreload.py”, line 226, in wrapper
fn(*args, **kwargs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py”, line 121, in inner_run
self.check(display_num_errors=True)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 385, in check
include_deployment_checks=include_deployment_checks,
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 372, in _run_checks
return checks.run_checks(**kwargs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/registry.py”, line 81, in run_checks
new_errors = check(app_configs=app_configs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 14, in check_url_config
return check_resolver(resolver)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 24, in check_resolver
for pattern in resolver.url_patterns:
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 310, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 303, in urlconf_module
return import_module(self.urlconf_name)
File “/home/vladimir/public.html/venv/lib/python3.5/importlib/__init__.py”, line 126, in import_module
return _bootstrap._gcd_import(name, package, level)
File “<frozen importlib._bootstrap>”, line 986, in _gcd_import
File “<frozen importlib._bootstrap>”, line 969, in _find_and_load
File “<frozen importlib._bootstrap>”, line 958, in _find_and_load_unlocked
File “<frozen importlib._bootstrap>”, line 673, in _load_unlocked
File “<frozen importlib._bootstrap_external>”, line 665, in exec_module
File “<frozen importlib._bootstrap>”, line 222, in _call_with_frames_removed
File “/home/vladimir/public.html/futbolkas/urls.py”, line 6, in <module>
url(r'^$', ‘main.views.home’),
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/conf/urls/__init__.py”, line 85, in url
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
Заранее благодарна откликнувшимся.
Офлайн
nina у кототорой на чем то юниксовом домашний пользователь vladimir . Не плохо.
Вам пишут на достаточно понятном английском:
view must be a callable or a list/tuple in the case of include().Даже если воспользоваться переводчиком который переведет как вид должен быть вызываемым или список / кортеж в случае включают (). становиться примерно понятно, что функция представления должна быть вызываемым объектом, т.е. способна быть вызвана на выполнение. Ругается на урлы - видимо потому, что он наткнулся на вашу main.views.home и ему что то не понравилось. Что именно вряд ли кто то скажет точно - пока не покажете что у вас во вьюхах.
Офлайн
Муж - глава семьи, когда убунту ставила, назвала так root пользователя… Без задней мысли, просто люблю супруга))))).
Офлайн
urls.py
from django.conf.urls import patterns, include, url
from django.contrib import admin
from . import views
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', ‘main.views.home’),
)
views.py
from django.shortcuts import render
from main.models import *
from django.http import HttpResponse, HttpResponseRedirect
from django.core.exceptions import ObjectDoesNotExist
from django.template.loader import render_to_string
from django.shortcuts import render
from django.core.context_processors import csrf
from datetime import*
import random
import string
# Create your views here.
def home(request):
tovars =
for x in range(0,3):
tovars.append(x)
context = {
‘title’: ‘Helloworld’,
‘tovars’: tovars,
}
return HttpResponse(render_to_string('index.html', context))
Офлайн
url(r'^$', ‘views.home’)
Офлайн
Не помогло…. Может я что то не так сделала? скрин прилагаю. Все время ругается на patterns, что не может его импортировать, но блин от куда!??? ImportError: cannot import name ‘patterns’ ImportError:
‘patterns’ - это что? библиотека или модуль? и указывает почему то ошибки в файлах виртуального окружения… а это для меня пока коробка-загадка)))) может через pip его можно поставить - ‘patterns’ в смысле…. Кодировку указала
Помогите, знающие люди… Вывод терминала при запуске сервера:
(venv) vladimir@vladimir-B85M-D2V:~/public.html$ alias python=python3
(venv) vladimir@vladimir-B85M-D2V:~/public.html$ python manage.py migrate main
Traceback (most recent call last):
File “manage.py”, line 12, in <module>
execute_from_command_line(sys.argv)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/__init__.py”, line 367, in execute_from_command_line
utility.execute()
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/__init__.py”, line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 305, in run_from_argv
self.execute(*args, **cmd_options)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 353, in execute
self.check()
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 385, in check
include_deployment_checks=include_deployment_checks,
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/commands/migrate.py”, line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 372, in _run_checks
return checks.run_checks(**kwargs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/registry.py”, line 81, in run_checks
new_errors = check(app_configs=app_configs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 14, in check_url_config
return check_resolver(resolver)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 24, in check_resolver
for pattern in resolver.url_patterns:
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 310, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 303, in urlconf_module
return import_module(self.urlconf_name)
File “/home/vladimir/public.html/venv/lib/python3.5/importlib/__init__.py”, line 126, in import_module
return _bootstrap._gcd_import(name, package, level)
File “<frozen importlib._bootstrap>”, line 986, in _gcd_import
File “<frozen importlib._bootstrap>”, line 969, in _find_and_load
File “<frozen importlib._bootstrap>”, line 958, in _find_and_load_unlocked
File “<frozen importlib._bootstrap>”, line 673, in _load_unlocked
File “<frozen importlib._bootstrap_external>”, line 665, in exec_module
File “<frozen importlib._bootstrap>”, line 222, in _call_with_frames_removed
File “/home/vladimir/public.html/futbolkas/urls.py”, line 4, in <module>
from django.conf.urls import patterns, include, url
ImportError: cannot import name ‘patterns’
Прикреплённый файлы:
Снимок экрана от 2016-09-04 14-31-58.png (333,1 KБ)
Офлайн
Точнее вот:
(venv) vladimir@vladimir-B85M-D2V:~/public.html$ python manage.py runserver
Performing system checks…
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fe46067b7b8>
Traceback (most recent call last):
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/autoreload.py”, line 226, in wrapper
fn(*args, **kwargs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/commands/runserver.py”, line 121, in inner_run
self.check(display_num_errors=True)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 385, in check
include_deployment_checks=include_deployment_checks,
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/management/base.py”, line 372, in _run_checks
return checks.run_checks(**kwargs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/registry.py”, line 81, in run_checks
new_errors = check(app_configs=app_configs)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 14, in check_url_config
return check_resolver(resolver)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/core/checks/urls.py”, line 24, in check_resolver
for pattern in resolver.url_patterns:
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 310, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/utils/functional.py”, line 35, in __get__
res = instance.__dict__ = self.func(instance)
File “/home/vladimir/public.html/venv/lib/python3.5/site-packages/django/urls/resolvers.py”, line 303, in urlconf_module
return import_module(self.urlconf_name)
File “/home/vladimir/public.html/venv/lib/python3.5/importlib/__init__.py”, line 126, in import_module
return _bootstrap._gcd_import(name, package, level)
File “<frozen importlib._bootstrap>”, line 986, in _gcd_import
File “<frozen importlib._bootstrap>”, line 969, in _find_and_load
File “<frozen importlib._bootstrap>”, line 958, in _find_and_load_unlocked
File “<frozen importlib._bootstrap>”, line 673, in _load_unlocked
File “<frozen importlib._bootstrap_external>”, line 665, in exec_module
File “<frozen importlib._bootstrap>”, line 222, in _call_with_frames_removed
File “/home/vladimir/public.html/futbolkas/urls.py”, line 4, in <module>
from django.conf.urls import patterns, include, url
ImportError: cannot import name ‘patterns’
Офлайн
1. применяйте тэг code
2. здесь смотрели?
3. в терминале выполните:
bash-3.2$ python manage.py shell Python 2.7.11 (default, Jan 22 2016, 16:30:50) Type "copyright", "credits" or "license" for more information. IPython 5.0.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In [1]: import django In [2]: django.setup() In [3]: help(django.conf.urls)
Help on package django.conf.urls in django.conf: NAME django.conf.urls FILE /usr/local/lib/python2.7/site-packages/django/conf/urls/__init__.py PACKAGE CONTENTS i18n static FUNCTIONS include(arg, namespace=None, app_name=None) url(regex, view, kwargs=None, name=None) DATA __all__ = ['handler400', 'handler403', 'handler404', 'handler500', 'in... handler400 = 'django.views.defaults.bad_request' handler403 = 'django.views.defaults.permission_denied' handler404 = 'django.views.defaults.page_not_found' handler500 = 'django.views.defaults.server_error' (END)
Отредактировано vic57 (Сен. 4, 2016 23:35:58)
Офлайн
так оно и есть
версия django у вас не соответствует вашему коду
Отредактировано vic57 (Сен. 5, 2016 11:40:07)
Офлайн
1. Хорошо, правда не знаю где)))) третий день к вам заглядываю, еще не все знаю, извиняюсь.
2. Здесь сейчас и смотрю… точнее занимаюсь, спасибо.
3. Да, действительно, версия джанго не сходится. Видео уроки больше смотреть не стану))) читаю оф.документацию, думаю дальше должно пойти по легче.
Всем большое спасибо!
Офлайн