Ich begann vor kurzem mit der Entwicklung von Django 1.9 für Python. Ich bin auch ein Neuling in Python. Arbeite einfach durch Beispiele und Codes, um Dinge zu lernen. kam ich einschließlich in django.conf.urls, die, wenn ich Fehler verursachte verursacht. Ich konnte nicht verstehen, warum das war? Weil ich es an anderen Stellen benutzt habe, die keine Fehler verursachen."Include" funktioniert seltsam
from django.conf.urls import url, include
from accounts import views as acc_views
urlpatterns = [
url(r'^home$', acc_views.home, name='accounts_home'),
]
Unten ist, wenn dies einen Fehler gibt. Hier
urlpatterns = [
url(r'^home$', include(acc_views.home), name='accounts_home'),
]
ist die Ausnahme:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x035424F8>
Traceback (most recent call last):
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\urlresolvers.py", line 419, in url_patterns
iter(patterns)
TypeError: 'function' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\checks\urls.py", line 27, in check_resolver
warnings.extend(check_resolver(pattern))
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\checks\urls.py", line 27, in check_resolver
warnings.extend(check_resolver(pattern))
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python35-32\VirtualENV\socialnetwork296\lib\site-packages\django\core\urlresolvers.py", line 426, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf '<function home at 0x03D45A50>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
Was umfassen ist eigentlich tun?
Welchen Fehler haben Sie? –
Hier ist der Fehler, http://hastebin.com/akilovumow.tex –
Bitte fügen Sie den Fehler zu Ihrer Frage durch Bearbeiten, anstatt eine externe Website zu verknüpfen! –