当我运行Django App时,我收到以下错误:
Unhandled exception in thread started by <function wrapper at 0x7f8449a387d0>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/root/soho-website/backend/project/urls.py", line 10, in <module>
url(r'', include('web.urls')),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/root/soho-website/backend/web/urls.py", line 6, in <module>
from web import views, models
File "/root/soho-website/backend/web/views.py", line 19, in <module>
from captcha.models import CaptchaStore
ImportError: No module named models
但是,如果我在urls.py文件中注释以下行:url(r'', include('web.urls')),
我定义了我的索引页面,我的应用程序正在工作。
我已经通过Pip(Captcha,Ckeditor,MySQL等)正确安装了所有应用程序
详细信息:
urls.py文件
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'project.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# Website URLs
url(r'', include('web.urls')),
# Admin URLs
url(r'^admin/', include(admin.site.urls)),
)
base.py文件(某些配置):
import os
from django.core.urlresolvers import set_urlconf
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ROOT_URLCONF = 'project.urls'
WSGI_APPLICATION = 'project.wsgi.application'
DOMAIN_URL = "http://MY_IP"
我的申请结构是:
我的配置有什么问题?
我已正确安装了PIP INSTALL的Captcha。在我的Installed_APPS中,我定义了验证码,如果我在urls.py文件中添加以下行:url(r'^captcha/', include('captcha.urls')),
,则错误仍然存在。
这是我的网站/ views.py:
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Python imports
import datetime
import json
# Django imports
from django.shortcuts import render, get_object_or_404
from django.views.generic import View, ListView, DetailView, YearArchiveView, \
MonthArchiveView, TemplateView, FormView
from django.http import Http404, HttpResponse
from django.template import loader, Context
from django.core.mail import EmailMultiAlternatives
from django.db.models import Q
from django.conf import settings
# Captcha imports
from captcha.models import CaptchaStore # This is the line where error occurs
from captcha.helpers import captcha_image_url
# APP imports.
from web.models import Slider, Woman, Article, CategoryArticle, CategoryWoman, \
CategoryBlog, Blog, Banner
from web.constans import MONTHS
from web.utils import women_dates_list
from web.forms import ContactForm, RegisterForm, ContactModelForm
抱歉我的英文。
Django-Ckeditor错误
Unhandled exception in thread started by <function wrapper at 0x7fe211911140>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/root/soho-website/backend/project/urls.py", line 10, in <module>
url(r'', include('web.urls')),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/root/soho-website/backend/web/urls.py", line 83, in <module>
(r'^ckeditor/', include('ckeditor.urls')),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named urls
这是我的web / urls.py
# Django imports
from django.conf.urls import patterns, include, url
from django.conf import settings
# App imports
from web import views, models
# URLs
urlpatterns = patterns('',
##
## URLS of the Website
##
# CAPTCHA
url(r'^captcha/', include('captcha.urls')),
# CKEDITOR
(r'^ckeditor/', include('ckeditor.urls')),
)
答案 0 :(得分:0)
也许您没有安装所需的验证码。 pip install captcha
安装this。它没有模型。您似乎需要django-simple-captcha。通过运行pip install django-simple-captcha
安装它。
<强>更新强>
将(r'^ckeditor/', include('ckeditor.urls')),
更改为(r'^ckeditor/', include('ckeditor_uploader.urls')),