一个易于使用的django应用程序,使静态网站。
django-static-sites的Python项目详细描述
#django static sites
*django static sites*是一个易于使用的*django*应用程序,允许您使用django
模板系统创建静态站点。您可以通过添加decorator来呈现现有的*django*视图,也可以创建为*django static sites*使用而优化的空项目。您可以为多个部署类型指定多个配置。
[github](https://github.com/ciotto/django static sites)
在python路径或*virtualenv*路径中安装*django static sites*
(`pip install django static sites`)或(`pip install https://github.com/ciotto/django static sites/archive/master.zip`)
2。通过"django static admin startproject project\u name"命令创建一个空的优化项目
3。移到"project\u name"文件夹,并通过"python manage.py startsite site\u name"命令创建站点
4。迁移"python manage.py migrate"
5。部署"python manage.py deploy"
6。启动服务器"python manage.py runserver"
7。在[http://127.0.0.0.0.1:8000](http://127.0.0.0.1:8000)**:-)**
如何使用
>如果要使用*django*模板系统,必须在"views.py"文件中添加一个函数,并添加
`@staticview`decorator:
``python
@staticview
@staticview
deindex(请求):
ctx={'title':'ctx={'title':'ctx>
你好,世界!}
return render_to_response('index.html',ctx,context_instance=requestcontext(request))
````
>和templates文件夹中的"index.html"模板文件:
``html
<;!
<;lt;lt;lt;lt;lt;meta charset="utf-8">;
<;meta charset="utf-8">;
<;lt;title>;{{{title}}<;lt;title>;
<;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;br/>>;
<;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;>;
``
在部署时(`python manage.py deploy`或*autodeploy*),*django static sites*使用
`index.html`模板创建"index.html"。
如果要添加呈现的javascript文件,可以创建一个视图:
``python
@static view(path={'demo':'asd/test.js',''''js/test.js'})
def js\u test(请求):
ctx={'title':'hello world!'}
返回render_to_response('test.js',ctx,context_instance=requestcontext(request))
````
``javascript
var text='{{title}';
警报(文本);
```
test.js`目标路径在`@staticview`装饰符中指定,并且对于不同的部署类型是不同的,因此
我们必须在"index.html"上下文中添加`'js`路径':js` test.path.get(deploy` type=deploy`类型)。`如果声明了deploy_type`则会传递给视图
函数。现在,我们可以在"index.html"文件中添加导入行:
``html
<;script type="text/javascript" src="{js\u path}">;<;/script>;
```
您可以通过"manage.py runserver--settings staticsites.tests.samples.samples戋name.settings"命令为此
示例启动部署服务器。
1其他示例。[你好世界](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/01 U你好世界)
2.[hello world(with static)](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/02 U hello U world)
3.[aws s3/cloudfront](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/03_aws)
4.[aws s3/cloudfront(multiple remote)](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/04_aws_multiple_deploy_type)
5.[ftp](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/05撸ftp)
\r/>\r\n添加到现有项目中
如果要将"django static sites"集成到现有项目中,必须:
1。在您的如果要使用Django Development Server为部署的静态站点提供服务,则安装的应用程序(替换django.contrib.staticfiles)
1。在"url.py"
``python
%s)?$'%get_default_index(deploy_type='dev'),
服务,
{
'文档根':get_deploy_root(deploy_type='dev'),'path':get_default_index(deploy_type='dev')
}
url(
r'^(?)p<;path>;*)$',
服务,
{
"文档根":获取部署根(部署类型='dev')
}
],
]
```````
默认情况下,使用"filesystemstorage"在本地部署
,但您可以使用具有正确设置的任何其他"storage"。在
[aws s3/cloudfront](https://github.com/ciotto/django-static-sites/tree/master/staticsites/tests/samples/03-aws)示例中,我使用[django存储](https://django-storages.readthedocs.org/)aws存储在amazon s3存储桶上进行部署。
字典~~~
*~~部署在多个远程~~
*添加参数检查并引发异常
*更新测试
*~~专用*设置*示例模块~~
*~~添加教程~~
*~~部署管理控制台~~
*django static sites*是一个易于使用的*django*应用程序,允许您使用django
模板系统创建静态站点。您可以通过添加decorator来呈现现有的*django*视图,也可以创建为*django static sites*使用而优化的空项目。您可以为多个部署类型指定多个配置。
[github](https://github.com/ciotto/django static sites)
在python路径或*virtualenv*路径中安装*django static sites*
(`pip install django static sites`)或(`pip install https://github.com/ciotto/django static sites/archive/master.zip`)
2。通过"django static admin startproject project\u name"命令创建一个空的优化项目
3。移到"project\u name"文件夹,并通过"python manage.py startsite site\u name"命令创建站点
4。迁移"python manage.py migrate"
5。部署"python manage.py deploy"
6。启动服务器"python manage.py runserver"
7。在[http://127.0.0.0.0.1:8000](http://127.0.0.0.1:8000)**:-)**
如何使用
>如果要使用*django*模板系统,必须在"views.py"文件中添加一个函数,并添加
`@staticview`decorator:
``python
@staticview
@staticview
deindex(请求):
ctx={'title':'ctx={'title':'ctx>
你好,世界!}
return render_to_response('index.html',ctx,context_instance=requestcontext(request))
````
>和templates文件夹中的"index.html"模板文件:
``html
<;!
<;lt;lt;lt;lt;lt;meta charset="utf-8">;
<;meta charset="utf-8">;
<;lt;title>;{{{title}}<;lt;title>;
<;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;br/>>;
<;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;lt;>;
``
在部署时(`python manage.py deploy`或*autodeploy*),*django static sites*使用
`index.html`模板创建"index.html"。
如果要添加呈现的javascript文件,可以创建一个视图:
``python
@static view(path={'demo':'asd/test.js',''''js/test.js'})
def js\u test(请求):
ctx={'title':'hello world!'}
返回render_to_response('test.js',ctx,context_instance=requestcontext(request))
````
``javascript
var text='{{title}';
警报(文本);
```
test.js`目标路径在`@staticview`装饰符中指定,并且对于不同的部署类型是不同的,因此
我们必须在"index.html"上下文中添加`'js`路径':js` test.path.get(deploy` type=deploy`类型)。`如果声明了deploy_type`则会传递给视图
函数。现在,我们可以在"index.html"文件中添加导入行:
``html
<;script type="text/javascript" src="{js\u path}">;<;/script>;
```
您可以通过"manage.py runserver--settings staticsites.tests.samples.samples戋name.settings"命令为此
示例启动部署服务器。
1其他示例。[你好世界](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/01 U你好世界)
2.[hello world(with static)](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/02 U hello U world)
3.[aws s3/cloudfront](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/03_aws)
4.[aws s3/cloudfront(multiple remote)](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/04_aws_multiple_deploy_type)
5.[ftp](https://github.com/ciotto/django static sites/tree/master/staticsites/tests/samples/05撸ftp)
\r/>\r\n添加到现有项目中
如果要将"django static sites"集成到现有项目中,必须:
1。在您的如果要使用Django Development Server为部署的静态站点提供服务,则安装的应用程序(替换django.contrib.staticfiles)
1。在"url.py"
``python
%s)?$'%get_default_index(deploy_type='dev'),
服务,
{
'文档根':get_deploy_root(deploy_type='dev'),'path':get_default_index(deploy_type='dev')
}
url(
r'^(?)p<;path>;*)$',
服务,
{
"文档根":获取部署根(部署类型='dev')
}
],
]
```````
默认情况下,使用"filesystemstorage"在本地部署
,但您可以使用具有正确设置的任何其他"storage"。在
[aws s3/cloudfront](https://github.com/ciotto/django-static-sites/tree/master/staticsites/tests/samples/03-aws)示例中,我使用[django存储](https://django-storages.readthedocs.org/)aws存储在amazon s3存储桶上进行部署。
字典~~~
*~~部署在多个远程~~
*添加参数检查并引发异常
*更新测试
*~~专用*设置*示例模块~~
*~~添加教程~~
*~~部署管理控制台~~