django如何使用restful风格

如何配置django静态文件路径

妙音 posted @ 2015年5月12日 09:54 in django , 2744 阅读
django默认无法直接访问静态文件(js、css、images),并且设置方法会与DEBUG相关

DEBUG=True时

要在settings中的配置STATICFILES_DIRS参数. 如下
# static目录url路径
STATIC_URL = '/static/'

#static目录磁盘路径
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'mysite/static'),
)

DEBUG=Flase时

在DEBUG=Flase时,不仅需要进行上面设置,而且要多加两处配置.
  • settings文件
STATIC_ROOT = '/homew/wyq/mysite/mysite/static'
  • urls.py文件
from django.conf import settings

if settings.DEBUG is False:
    urlpatterns += patterns('',
        url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.STATIC_ROOT,
        }),
    )
 

 

Avatar_small
nagasaon hk 说:
2020年11月17日 14:31

cheers for the actual article i have recently been on the lookout with regard to this kind of advice on the net for sum time right now so many thanks

Avatar_small
factory material han 说:
2020年11月18日 15:52

An automated guided vehicle or automatic guided vehicle (AGV) is a portable robot that follows along with marked magnets or lasers for navigation. They are most often used in industrial applications to transport heavy materials around a large industrial building, such as a factory or warehouse.

Avatar_small
UMAIR 说:
2020年12月15日 20:11

Maharashtra Board 12th Model Paper 2021 Here provides Department Maharashtra State Board of Secondary & Higher Secondary Education (MSBSHSE) Students those who are going to Preparing Class MSBSHSE HSC public exams march 2021 can download Maha HSC 12th Model Question Paper 2021 in Official Website mahahsscboard.maharashtra.gov.in, you stack of Maha Board 12th Class Question Paper which comprises of Previous year model Question Paper Maharashtra Academic Council is also known as the Maharashtra 12thBlueprint 2021 Directorate of Government Examinations students can enhance their preparation Maha Board 12th Model Paper 2021 in examination point of view Public Examination tests will be Conducted with New Syllabus in all Private and Government College Previous Maharashtra 12th Blueprint Here Available They are Given Below.

Avatar_small
Aviation Forum 说:
2020年12月30日 15:09

This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info:

Avatar_small
Pilot Jobs 说:
2020年12月30日 17:52

I simply believed it might be a concept to publish in case other people had been having issues studying however I'm just a little uncertain basically 'm permitted to place titles as well as handles upon right here.

Avatar_small
Sikkim 7th Class Te 说:
2023年9月13日 10:55

Board of Secondary Education Sikkim Adopt By has NCERT Textbooks at the High School Standard in Prepare by Senior experts. Sikkim Board once Publishes the Sikkim 7th Standard Textbooks 2024 Other Study Sikkim 7th Class Textbook 2024 materials on the official web site, we will update the Information on this page. Sikkim Board Assam e-Books 2024 Latest Version to be Upload Every Year in Online Mode.Textbooks are Very Important to Students on the Preparations of the Monthly and Final Examination.Sikkim Secondary Education Board Follows NCERT Curriculum These Textbooks are Updated as per the Syllabus Prescribed by Sikkim Board.

Avatar_small
qk 说:
2023年9月19日 03:07

I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. mahjong ways 2

Avatar_small
qk 说:
2023年9月22日 19:55

The post is written in very a good manner and it contains many useful information for me. Jogo do Tigre

Avatar_small
qk 说:
2023年10月09日 21:45

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often. taruhan olahraga

Avatar_small
qk 说:
2023年10月11日 20:59

This blog is so nice to me. I will keep on coming here again and again. Visit my link as well.. Fortune Tiger

Avatar_small
qk 说:
2023年10月11日 21:16

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. NEOTONICS

Avatar_small
qk 说:
2023年10月17日 02:19

Thanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. AVALIADOR PREMIADO

Avatar_small
qk 说:
2023年10月22日 00:33

It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. บาคาร่าเว็บไหนดี2022

Avatar_small
qk 说:
2023年11月01日 20:09

I would like to say that this blog really convinced me to do it! Thanks, very good post. JOGO DO TIGRE

Avatar_small
qk 说:
2023年11月01日 20:26

You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!! FORTUNE TIGER

Avatar_small
qk 说:
2023年11月01日 20:36

Great post, you have pointed out some fantastic points , I likewise think this s a very wonderful website. CODIGOS LUCRATIVOS

Avatar_small
Award-winning candid 说:
2023年12月02日 02:47

Magica By Rish Agarwal is the best wedding photographer in New Delhi, India who captures candid moments and has an award-winning portfolio in Indian Weddings
#Best Wedding Photographer India

Avatar_small
qk 说:
2023年12月11日 19:48

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! master 333

Avatar_small
qk 说:
2023年12月11日 20:30

I have recently started a blog, the info you provide on this site has helped me greatly. Thanks for all of your time & work. pamela poker

Avatar_small
qk 说:
2023年12月18日 18:28

Hi there! Nice stuff, do keep me posted when you post again something like this! Brojp


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter