django1.3静态文件问题
你好,我是 django 的新手,我为我的项目进行用户身份验证,它工作正常。
我在项目根文件夹中创建了一个名为“static”的文件夹[现在在本地开发中],并在setting.py中进行了必要的编辑,
我的第一页 [其中包含登录表单] 显示图像并成功使用 css 文件,如果登录成功帐户/个人资料 url 映射到视图,则反过来 导致模板“LoginSuccess.html”,但不显示图像和 css 文件。
问题是它不从静态文件夹中获取图像。 我的命令提示符如下所示
Django version 1.3, using settings 'SecondPrjt.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[20/Sep/2011 22:11:47] "GET / HTTP/1.1" 200 5394
[20/Sep/2011 22:11:47] "GET /static/css/style.css HTTP/1.1" 200 3612
[20/Sep/2011 22:11:47] "GET /static/images/favicon.ico HTTP/1.1" 200 1150
[20/Sep/2011 22:12:10] "POST / HTTP/1.1" 302 0
[20/Sep/2011 22:12:10] "GET /accounts/profile/ HTTP/1.1" 200 1930
[20/Sep/2011 22:12:10] "GET /accounts/profile/css/style.css HTTP/1.1" 404 2758
[20/Sep/2011 22:12:10] "GET /accounts/profile/images/logo.jpg HTTP/1.1" 404 2764
[20/Sep/2011 22:12:10] "GET /accounts/profile/images/rss.jpg HTTP/1.1" 404 2761
[20/Sep/2011 22:12:10] "GET /accounts/profile/images/but1.gif HTTP/1.1" 404 2764
Also am confused about the HTTP 302 which not related to the static files
注意:我使用继承我所有模板的base.html(调用css文件,一些图像)
url.py (r'^$',登录),
(r'^accounts/profile/$',views.loginsuccess),
(r'^帐户/注销/$',注销),
hi, I am new to django,I doing user authentication for my project,Well its works properly.
I have created a folder named 'static' in my projects root folder[now am in local devlopment] and necessary editing in setting.py ,
My first page[which contains a login form] displays the images and uses the css file successfully,If login success accounts/profile url map to a view ,which in turn
leads to a template 'LoginSuccess.html' but which doesn't displays the images,and css files.
The problem is it doesn't fetches the images from static folder.
My command prompt looks as follows
0 errors found
Django version 1.3, using settings 'SecondPrjt.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[20/Sep/2011 22:11:47] "GET / HTTP/1.1" 200 5394
[20/Sep/2011 22:11:47] "GET /static/css/style.css HTTP/1.1" 200 3612
[20/Sep/2011 22:11:47] "GET /static/images/favicon.ico HTTP/1.1" 200 1150
[20/Sep/2011 22:12:10] "POST / HTTP/1.1" 302 0
[20/Sep/2011 22:12:10] "GET /accounts/profile/ HTTP/1.1" 200 1930
[20/Sep/2011 22:12:10] "GET /accounts/profile/css/style.css HTTP/1.1" 404 2758
[20/Sep/2011 22:12:10] "GET /accounts/profile/images/logo.jpg HTTP/1.1" 404 2764
[20/Sep/2011 22:12:10] "GET /accounts/profile/images/rss.jpg HTTP/1.1" 404 2761
[20/Sep/2011 22:12:10] "GET /accounts/profile/images/but1.gif HTTP/1.1" 404 2764
Also am confused about the HTTP 302 which not related to the static files
Note: I use a base.html(calls css files,some images) which inherits all of my templates
urls.py
(r'^$',login),
(r'^accounts/profile/$',views.loginsuccess),
(r'^accounts/logout/$',logout),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在渲染时忘记传递上下文的问题
返回 render_to_response('user/LoginSuccess.html',context_instance=RequestContext(请求)
The problem I forgot to pass context while render
return render_to_response('user/LoginSuccess.html',context_instance=RequestContext(request)