Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.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_Django Templates_Django Admin - Fatal编程技术网

Python 无法访问我的django管理面板

Python 无法访问我的django管理面板,python,django,django-templates,django-admin,Python,Django,Django Templates,Django Admin,url.py from django.conf import settings from django.conf.urls import patterns, include, url from basic_code.settings import STATIC_ROOT from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/doc/' , inclu

url.py

from django.conf import settings 
from django.conf.urls import patterns, include, url
from basic_code.settings import STATIC_ROOT

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/doc/' , include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    (r'media(?P<path>. *)$', 'django.views.static.serve', {'document_root':          settings.MEDIA_ROOT}),
(r'static(?P<path>. *)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
url(r'^$', 'contact.views.home'),
url(r'^static/(.*)$', 'django.views.static.serve', {'document_root': STATIC_ROOT, 'show_indexes' : True}),
url(r'^templates/$', 'templates.welcome', name="welcome"),
在编辑URL和设置之前,我有syncdb和collectstatic。 现在终端显示

$ python2.7 manage.py collectstatic
Unknown command: 'collectstatic'
Type 'manage.py help' for usage.
当我收集静电时

当我访问www.website.com/admin时,我会得到:

ImportError at /admin/
No module named templates
Request Method: GET
Request URL:    http://www.website.com/admin/
Django Version: 1.5
Exception Type: ImportError
Exception Value:    
No module named templates
Exception Location: /home/user/webapps/appname/lib/python2.7/django/utils/importlib.py in import_module, line 35
Python Executable:  /usr/local/bin/python
Python Version: 2.7.5 

提前谢谢你

检查您的模块
模板

问题在于以下几行:

url(r'^templates/$', 'templates.welcome', name="welcome"),

你做得对吗?怎么会?我添加了这一行,以便能够访问templates文件夹下的welcome.html页面。但是,我可能错了,这是我的第一个网站。您需要实际呈现welcome.html文件。使用通用视图:
TemplateView.as\u视图(template\u name=“welcome.html”)
我在哪里放置TemplateView.as\u视图(template\u name=“welcome.html”)?阅读有关视图的内容:
url(r'^templates/$', 'templates.welcome', name="welcome"),