Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.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 Django设置和视图映射错误_Python_Django_Node.js_Sqlite - Fatal编程技术网

Python Django设置和视图映射错误

Python Django设置和视图映射错误,python,django,node.js,sqlite,Python,Django,Node.js,Sqlite,我已经使用Django(1.8.5)构建了一个实时通知应用程序。我正在使用django服务器,Nodejs作为推送服务器,ishout.js[Nodejs+redis+express.jsapi]。所以我按照说明安装了它们 请建议如何修复此错误: settings.py文件 """ #Django settings for realtimenotif project. Generated by 'django-admin startproject' using Django 1.8.5. F

我已经使用Django(1.8.5)构建了一个实时通知应用程序。我正在使用django服务器,Nodejs作为推送服务器,ishout.js[Nodejs+redis+express.jsapi]。所以我按照说明安装了它们

请建议如何修复此错误:

settings.py文件

"""
#Django settings for realtimenotif project.

Generated by 'django-admin startproject' using Django 1.8.5.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'gvvs-0*-cohfbm@()*nyt&0u!77sc_8vnw%1afpkmhi&y-6&ds'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True


ADMINS = (
             #'arunsingh','arunsingh.in@gmail.com'
    )

MANAGERS = ADMINS

ALLOWED_HOSTS = ["*"]


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'drealtime',
    'sendnotif',

)

MIDDLEWARE_CLASSES = (

    'django.middleware.common.CommonMiddleware',
    'drealtime.middleware.iShoutCookieMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'realtimenotif.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'debug':DEBUG,
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',

            ],
        },
    },
]



WSGI_APPLICATION = 'realtimenotif.wsgi.application'





# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

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

        #The following settings are not used with sqlite3:
        'USER':'',
        'PASSWORD':'',
        'HOST':'',                  # Empty for localhost through domain sockets,127.0.0.1
        'PORT':'',                  # Set to empty string for default
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = '/static/'
url.py文件

"""realtimenotif URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import patterns, include, url
#from sendnotif.views import home, alert

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns(['',

    url(r'^$', 'sendnotif.views.home', name='home'),
    #url(r'^$', home, name='home'),
    url(r'^alert/$', 'sendnotif.views.alert', name='alert'),
    #url(r'^alert/$', alert, name='alert'),

    url(r'^accounts/login/$','django.contrib.auth.views.login',name='login'),

    #uncomment the next line to enable the admin:
    url(r'^admin/$', include(admin.site.urls)), 
]   )
Django服务器正在启动,它说可以工作,并给出了这个消息

“您之所以看到此消息,是因为您的 Django设置文件,但您尚未配置任何URL。请访问 工作!”

对于我在settings.py和views.py文件中必须进行的更改,请建议解决方法的指针。我已经通过和初学者教程,但没有救援


您可以在

看到项目源代码,Django无法找到您的URL.py文件

您需要将根URLconf指向
realtimenotif.url
模块。创建顶级
url.py
并使用include(),例如:

yoursite/url.py:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^/', include('realtimenotif.urls')),
    url(r'^admin/', include(admin.site.urls)),
]

或者将您的URL.py从realtimenotif移动到顶级文件夹。

您应该解决(并阅读)该问题中的评论,并据此更新/编辑您的问题,而不是创建一个新的URL.py。请不要将链接发布到您的存储库,并要求我们修复您的代码。在堆栈溢出上在此发布相关代码。您可能会发现,通过本教程,让简单的民意调查应用程序工作起来会更容易,而不是一下子跳进并安装Django、node、ishout等等。@Alasdair我根本没有要求修复代码,repo只是为了了望,下一次以后,我会尽力发布相关代码,主持人在上一个问题中建议,它并不是集中在一个问题上,而是一个广泛的问题,因此我试图通过缩小问题的范围来解决这个问题。您集中在一个错误上,但您没有向我们展示导致问题的代码。目前,您要求我们查看您的存储库,以找出问题所在。您可以选择您的问题并添加相关代码。特别是,您需要显示设置中的
ROOT\u URLCONF
,并显示它指向的url.py的内容。我只是尝试添加代码,但没有进行编辑,请指出问题所在。