Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入错误/login没有名为login的模块_Python_Django_Django Views_Django Urls - Fatal编程技术网

Python 导入错误/login没有名为login的模块

Python 导入错误/login没有名为login的模块,python,django,django-views,django-urls,Python,Django,Django Views,Django Urls,我曾尝试跟随一些django教程创建登录,但我一直都在尝试 导入错误/login没有名为login的模块 我的文件结构是: -src -logins -__init__.py -admin.py -models.py -views.py -testproject -__init__.py -settings.py -urls.py 设置.py import os BASE_D

我曾尝试跟随一些django教程创建登录,但我一直都在尝试

导入错误/login没有名为login的模块

我的文件结构是:

 -src
     -logins
       -__init__.py
       -admin.py
       -models.py
       -views.py
     -testproject
       -__init__.py
       -settings.py
       -urls.py
设置.py

import os
BASE_DIR = '/Users/chrismeek/Documents/Python/Testenv'

SECRET_KEY = ''

DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'logins',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'testproject.urls'

WSGI_APPLICATION = 'testproject.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

TEMPLATE_DIRS = (
    '/Users/chrismeek/Documents/Python/Testenv/src/static/templates',
)
url.py

from django.conf.urls import patterns, url, include

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^login', 'login.views.login', name='login'),
    url(r'^auth/$', 'login.views.auth_view', name='auth_view'),
    url(r'^logout/$', 'login.views.logout', name='logout'),
    url(r'^loggedin/$', 'login.views.loggedin', name='loggedin'),
    url(r'^invalid/$', 'login.views.invalid', name='invalid'),

    url(r'^admin/', include(admin.site.urls)),
)
views.py

from django.shortcuts import render, render_to_response
from django.http import HttpResponseRedirect
from django.contrib import auth
from django.corecontext_processors import csrf

# Create your views here.
def login(request):
    c = {}
    c.update(csrf(request))
    return render_to_response('login.html', c)

def auth_view(request):
    username = request.POST.get('username', '')
    password = request.POST.get('password', '')
    user = auth.authenticate(username=username, password=password)

    if user is not None:
        auth.login(request,user)
        return HttpResponseRedirect('loggedin')
    else:
        return HttpResponseRedirect('invalid')

def loggin(request):
    return render_to_response('loggedin.html', {'full_name': request.user.username})

def invalid_login(request):
    return render_to_response('invalid_login.html')

def logout(request):
    auth.logout(request)
    return render_to_response('logout.html')
这让我快发疯了,如果能得到任何帮助,我将不胜感激。谢谢

您的应用程序被称为“登录”,而不是“登录”:

请将您的问题与错误的全文一起回溯。
url(r'^login', 'logins.views.login', name='login'),
                     ^