Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.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活塞的基本http身份验证_Python_Django_Django Piston - Fatal编程技术网

Python 使用django活塞的基本http身份验证

Python 使用django活塞的基本http身份验证,python,django,django-piston,Python,Django,Django Piston,我是个新手。我在官方网站上看到了代码片段(粘贴在下面)。 问题是如何将其部署到服务器?在哪里设置用户名和密码凭据?在Apache的httpd.conf文件中 从django.conf.url.defaults导入* 从活塞资源导入资源 从活塞身份验证导入HttpBasicAuthentication 从myapp.handlers导入BlogPostHandler、ArricryDataHandler auth=HttpBasicAuthentication(realm=“我的领域”) ad=

我是个新手。我在官方网站上看到了代码片段(粘贴在下面)。 问题是如何将其部署到服务器?在哪里设置用户名和密码凭据?在Apache的httpd.conf文件中


从django.conf.url.defaults导入*
从活塞资源导入资源
从活塞身份验证导入HttpBasicAuthentication
从myapp.handlers导入BlogPostHandler、ArricryDataHandler
auth=HttpBasicAuthentication(realm=“我的领域”)
ad={'authentication':auth}
blogpost_resource=resource(handler=BlogPostHandler,**ad)
任意资源=资源(处理程序=任意数据处理程序,**ad)
urlpatterns+=模式(“”,
url(r'^posts/(?P[^/]+)/$,blogpost_资源),
url(r'^other/(?P[^/]+)/(?P.+)/$),任意资源),
)

默认情况下
活塞。身份验证。HttpBasicAuthentication
使用 检查凭证

换句话说,您只需创建普通Django用户即可“设置用户名和密码凭据”。

这是什么?德扬戈?活塞?
from django.conf.urls.defaults import *
from piston.resource import Resource
from piston.authentication import HttpBasicAuthentication

from myapp.handlers import BlogPostHandler, ArbitraryDataHandler

auth = HttpBasicAuthentication(realm="My Realm")
ad = { 'authentication': auth }

blogpost_resource = Resource(handler=BlogPostHandler, **ad)
arbitrary_resource = Resource(handler=ArbitraryDataHandler, **ad)

urlpatterns += patterns('',
    url(r'^posts/(?P<post_slug>[^/]+)/$', blogpost_resource), 
    url(r'^other/(?P<username>[^/]+)/(?P<data>.+)/$', arbitrary_resource), 
)