我无法找到urls.py的错误

时间:2016-02-10 18:23:13

标签: python django django-views django-urls

我无法找到bug的位置。这是我与django的开始。如果有人帮助我,我会感激不尽。

urls.py:

from django.conf.urls import url, patterns, include
from django.contrib import admin
from superlista.lists import views

urlpatterns = [
#    url(r'^admin/', admin.site.urls),
    url(r'^$', views.home_page, name='home'),
]

views.py:

from django.shortcuts import render


# Create your views here.
def home_page():
    pass

directory view

python manage.py runserver

Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03917468>
Traceback (most recent call last):
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
    return check_resolver(resolver)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], 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 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\vnbox\PycharmProjects\kurs_h\superlista\superlista\urls.py", line 19, in <module>
    from superlista.lists import views
ImportError: No module named 'superlista.lists'

我无法找到bug的位置。这是我与django的开始。如果有人帮助我,我会感激不尽。

1 个答案:

答案 0 :(得分:1)

根据您的文件夹结构截图判断,外部superlista是项目根目录,已安装的应用程序为listsINSTALLED_APPS

如果您已正确定义from lists import views 设置,则导入应为:

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" />



<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="192dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:contentScrim="@color/primary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp">




    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        app:layout_scrollFlags="scroll|enterAlways"
        android:layout_height="?attr/actionBarSize"
        app:layout_collapseMode="pin"/>


        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"/>


    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>


<android.support.v7.widget.RecyclerView
    android:id="@+id/days_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>